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

ActionErrors没有提示信息

2014-01-26 
ActionErrors没有提示信息,这是我的 actionform :import org.apache.struts.action.*import javax.servlet

ActionErrors没有提示信息,这是我的 actionform :
 
  import org.apache.struts.action.*;
  import javax.servlet.http.*;
  import java.io.Serializable;
  public class OrderCarForm extends org.apache.struts.validator.ValidatorForm
  implements Serializable {
  private String errormessage;
  private String password;
  private String username;
 
 
  public OrderCarForm()
  {
  }
 
 
  public String getErrormessage()
  {
  return errormessage;
  }
  public void setErrormessage(String errormessage) {
  this.errormessage = errormessage;
  }
  public String getPassword() {
  return password;
  }
  public void setPassword(String password) {
  this.password = password;
  }
 
  public String getUsername() {
  return username;
  }
  public void setUsername(String username) {
  this.username = username;
  }
 
  public ActionErrors validate(ActionMapping actionMapping, HttpServletRequest httpServletRequest)
  {
  /**@todo: finish this method, this is just the skeleton.*/
  ActionErrors errors = new ActionErrors();
  OrderCarForm form = new OrderCarForm();
  try
  {
  if (username.equals("")) {
  errors.add("username", new ActionError("username.errors"));
  //errors.add(errors.GLOBAL_MESSAGE, new ActionMessage("username.errors"));
  form.setErrormessage("用户名称不可以为空!");
  //errors.add("error",new ActionMessage("用户名不可以为空!")) ;
  }
  if (password.equals(""))
  errors.add("password", new ActionError("password.error"));
  }
  catch(Exception e)
  {
  System.out.println(e.getMessage() );
  errors = null;
  }
  return errors;
  }
 
  public void reset(ActionMapping actionMapping, HttpServletRequest httpServletRequest)
  {
 
  }
  }
 
  这是我的 action ;
  import org.apache.struts.action.*;
  import javax.servlet.http.*;
  import org.apache.commons.logging.Log;         

热点排行