奇怪為什麼登陸失敗的時候 沒有錯誤提示.這個問題困擾了N久
仔細看了下,發現在處理登陸失敗情況跳轉的頁面 原代碼用的是mapping.getInputForward();
斷點跟蹤了一下 這句運行好以後
mapping.getInputForward();是個什麼東西?!百度了下原來和這個是
擷取action當中input中的值對應的地址
<action path="/test"
type="org.apache.struts.webapp.example.TestAction"
name="testForm"
scope="request"
input="testInput">
<forward name="testInput" path="/testInput.jsp"/>
</action>
getInputForward();擷取的就是action中input裡的testinput,通過testinput又找到forward裡這個別名對應的path/testInput.jsp
mapping.getInput()擷取的是action中input裡的testinput字串
到這裡一切就明了了.
為什麼用mapping.getInputForward();了以後就沒有錯誤提示資訊呢 因為struts裡沒有input的配置
配置..運行..OK
loginAction代碼
public ActionForward login(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
MemLoginForm memLoginForm = (MemLoginForm) form;
MemDAO service = new MemDAOImpl();
ActionForward forward = null;
ActionMessages msgs = new ActionMessages();
try{
Member mem = service.memLogin(memLoginForm.getLoginName(), memLoginForm.getLoginPwd());
if (mem!=null){
request.getSession().setAttribute("member", mem);
forward = new ActionForward("/mer.do?method=browseIndexMer");
}else{
//等價語句
//forward = new ActionForward("/mer.do?method=browseIndexMer");
forward = mapping.getInputForward();
msgs.add("loginError",new ActionMessage(Constants.ADMIN_LOGINERROR_KEY));
saveErrors(request, msgs);
}
}catch(Exception ex){
logger.info("在執行LoginAction類中的login方法時出錯:\n");
ex.printStackTrace();
}
return forward;
}
轉載自:http://www.tiansky.net:8892/DBbbs/viewthread.jsp?tid=236&extra=page%3D1