日期:2014-05-20  浏览次数:20819 次

求救:一个struts 中的 action mapping不知道该怎么写了、、、、
public   ActionForward   execute(ActionMapping   mapping,   ActionForm   form,
HttpServletRequest   request,   HttpServletResponse   response)   {
DispForm   dispForm   =   (DispForm)   form;//   TODO   Auto-generated   method   stub
ActionMapping   am=null;

if(mapping.getAttribute().length()==0){
String   mess= " <script   language= 'javascript '> alert( 'error   message! '); </script> ";
request.setAttribute( "mess ",   "mess ");
am.findForward( "error ");
}   else   {
request.setAttribute( "mess ",   dispForm.getName());
am.findForward( "disp ");
}
return   am;
}


我想在程序中只有一个return   语句,可是这么写不对,我望记怎么写了,麻烦高手解答

------解决方案--------------------
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
DispForm dispForm = (DispForm) form;// TODO Auto-generated method stub
ActionForward af=null;

if(mapping.getAttribute().length()==0){
String mess= " <script language= 'javascript '> alert( 'error message! '); </script> ";
request.setAttribute( "mess ", "mess ");
af=mapping.findForward( "error ");
} else {
request.setAttribute( "mess ", dispForm.getName());
af=maping.findForward( "disp ");
}
return af;
}
------解决方案--------------------
关注
------解决方案--------------------
关注中
------解决方案--------------------
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
DispForm dispForm = (DispForm) form;
String forward = " ";

if(mapping.getAttribute().length() == 0){
String mess= " <script language= 'javascript '> alert( 'error message! '); </script> ";
request.setAttribute( "mess ", "mess ");
forward = "error ";
}
else {
request.setAttribute( "mess ", dispForm.getName());
forward = "disp ";
}
return mapping.findForward(forward);
}
------解决方案--------------------
up楼上