首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Exception >

Struts里ActionErrors saveErrors()问题,谁能帮我?

2014-01-26 
package helloimport javax.servlet.RequestDispatcherimport javax.servlet.ServletExceptionimport ja

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

热点排行