struts在代码中动态组装重定向请求

来源:互联网 发布:cad软件自学网 编辑:程序博客网 时间:2024/06/06 07:06
ActionRedirect是ActionForward 的一个子类,其设计来用于重定向请求,支持在运行时添加参数,用来重定向request,支持运行时URL传递的参数。

public ActionForward perform(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response) 
{
     
        .................

         String sPath 
= "/main/login.do";
         ActionRedirect    forward 
= new ActionRedirect(null, sPath, "");

         forward.addParameter(
"userName", name);
         forward.addParameter(
"password", password);

         
return forward;
}