struts1.1 saveErrors()

lee1013 lee1013 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
struts1.1的Action类里调用了saveErrors(),编译运行没有问题,但这种写法好像不被推荐.
我想从Acion重定向到输入页面,该怎么做。。。



public class LogonAction extends Action {

public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServerException, UserDirectoryException {

LogonForm user = (LogonForm) form;
String username = user.getUsername();
String password = user.getPassword();

boolean validate = false;
try {
validate = isUserLogon(username, password);
if (!validate) {
throw new UserDirectoryException("aaa");
}
} catch (UserDirectoryException e) {
ActionErrors errors = new ActionErrors();
errors.add("connect",new ActionMessage("error.logon.connect"));
saveErrors(request,errors);
return new ActionForward(mapping.getInput());
}

HttpSession session = request.getSession();
session.setAttribute(Constants.USER_KEY, user);

return mapping.findForward(Constants.WELCOME);
}

/**
* @param username
* @param password
* @return
*/
private boolean isUserLogon(String username, String password)
throws UserDirectoryException, IOException {
return UserDirectory.getInstance().isValidPassword(username,password);
}

}
...全文
评论 2
收藏 已收藏
分享
返回顶部
lee1013
Java EE 67,535 成员 225,843 内容