struts的ActionRedirect类

ActionRedirect类时ActionForward的子类,所以在项目当中也可以使用ActionRedirect类来进行action请求的转发。但是它有一个好处就是在转发时可以对路径进行动态的添加参数:

public ActionForward execute(ActionMapping mapping,
                              ActionForm form,
                              HttpServletRequest request,
                              HttpServletResponse response)
         throws Exception {
     ActionRedirect redirect =
             new ActionRedirect(mapping.findForward("doRedirect"));
     redirect.addParameter("param1","value1");
     redirect.addParameter("param2","2");
     redirect.addParameter("param3","3.0");
     return redirect;
 }


 

你可能感兴趣的:(exception,struts,action,redirect)