UserForm.java
上传用户:jishiqi_cj
上传日期:2022-08-08
资源大小:24765k
文件大小:1k
- package classmate;
- import org.apache.struts.action.ActionForm;
- import org.apache.struts.action.ActionMapping;
- import javax.servlet.http.HttpServletRequest;
- import org.apache.struts.action.ActionErrors;
- import org.apache.struts.action.ActionMessage;
- public class UserForm extends ActionForm{
- private String name = null; //用户名
- private String psw = null; //密码
- public UserForm(){}
- public void setName(String name) {
- this.name = name;
- }
- public String getName() {
- return name;
- }
- public void setPsw(String psw) {
- this.psw = psw;
- }
- public String getPsw() {
- return psw;
- }
-
- public void reset(ActionMapping mapping,
- HttpServletRequest request) {
- this.name = null;
- this.psw = null;
- }
- public ActionErrors validate(ActionMapping mapping,
- HttpServletRequest request) {
- ActionErrors errors = new ActionErrors();
- if ((name == null) || (name.equals(""))){
- errors.add(ActionErrors.GLOBAL_MESSAGE,
- new ActionMessage("error.name.required"));
- }
- if((psw == null) || (psw.equals(""))){
- errors.add(ActionErrors.GLOBAL_MESSAGE,new ActionMessage("error.psw.required"));
- }
- return errors;
- }
-
-
- }