Struts里ActionErrors saveErrors()问题,谁能帮我?
点击右边红色标题查看本文完整版:Struts里ActionErrors saveErrors()问题,谁能帮我?
package hello;
?
? import javax.servlet.RequestDispatcher;
? import javax.servlet.ServletException;
? import javax.servlet.http.HttpServletRequest;
? import javax.servlet.http.HttpSession;
? import javax.servlet.http.HttpServletResponse;
?
? import org.apache.struts.action.Action;
? import org.apache.struts.action.ActionMessage;
? import org.apache.struts.action.ActionMessages;
? import org.apache.struts.action.ActionForm;
? import org.apache.struts.action.ActionForward;
? import org.apache.struts.action.ActionMapping;
? import org.apache.struts.util.MessageResources;
?
? public final class HelloAction extends Action {
?
? public ActionForward execute(ActionMapping mapping,
? ? ? ActionForm form,
? ? ? HttpServletRequest request,
? ? ? HttpServletResponse response)
? throws Exception {
? MessageResources messages = getResources(request);
?
? ActionMessages errors = new ActionMessages();
? String userName = ((HelloForm) form).getUserName();
?
? String badUserName = "Monster";
?
? if (userName.equalsIgnoreCase(badUserName)) {
? errors.add("username", new ActionMessage("hello.dont.talk.to.monster", badUserName ));
? saveErrors(request, errors);这句话出错了,我要怎么解决?
? return (new ActionForward(mapping.getInput()));
? }
?
?
? PersonBean pb = new PersonBean();
? pb.setUserName(userName);
? pb.saveToPersistentStore();
?
?
? request.setAttribute( Constants.PERSON_KEY, pb);
?
? // Remove the Form Bean - don't need to carry values forward
? request.removeAttribute(mapping.getAttribute());
?
? // Forward control to the specified success URI
? return (mapping.findForward("SayHello"));
?
? }