struts在代碼中動態組裝重定向請求

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;
}

                
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章