📄 loginform.java
字号:
package com.haizi.struts.action;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
public class LoginForm extends ActionForm {
private String name;
private String password;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public LoginForm() {
super();
resetFields();
}
protected void resetFields() {
this.name = null;
this.password = null;
}
public void reset(ActionMapping mapping, HttpServletRequest req) {
super.reset(mapping, req);
}
public ActionErrors validate(ActionMapping mapping, HttpServletRequest req) {
ActionErrors errors = new ActionErrors();
if(getName() == null || getName().length() < 1) {
errors.add( ActionErrors.GLOBAL_ERROR,
new ActionError("global.required", "name" ));
}
if(getPassword() == null || getPassword().length() < 1) {
errors.add( ActionErrors.GLOBAL_ERROR,
new ActionError("global.required", "password" ));
}
return errors;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -