struts1.1 saveErrors()
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);
}
}