UserForm.java
上传用户:jishiqi_cj
上传日期:2022-08-08
资源大小:24765k
文件大小:1k
源码类别:

Java编程

开发平台:

Java

  1. package test;
  2. import org.apache.struts.action.ActionForm;
  3. import org.apache.struts.action.ActionMapping;
  4. import org.apache.struts.action.ActionError;
  5. import org.apache.struts.action.ActionErrors;
  6. import javax.servlet.http.HttpServletRequest;
  7. import javax.servlet.http.HttpServletResponse;
  8. public class UserForm extends ActionForm{  
  9. private String name = null; //用户名  
  10. private String psw = null; //密码 
  11. public UserForm(){}
  12. public void setName(String name) {
  13. this.name = name;
  14. }  
  15. public String getName() {
  16. return name;
  17. }  
  18. public void setPsw(String psw) {
  19. this.psw = psw;
  20. }  
  21. public String getPsw() {
  22. return psw;
  23. }
  24. public void reset(ActionMapping mapping,
  25. HttpServletRequest request) {
  26. this.name = null;
  27. this.psw = null;
  28. }
  29. public ActionErrors validate(ActionMapping mapping,
  30. HttpServletRequest request) {
  31. ActionErrors errors = new ActionErrors();
  32. if ((name == null) || (name.equals(""))){
  33. errors.add("name",
  34. new ActionError("error.regist.name.required"));
  35. }
  36. if((psw == null) || (psw.equals(""))){
  37. errors.add("psw",
  38. new ActionError("error.regist.psw.required"));
  39. }
  40. return errors;
  41. }
  42. }