loginform.java
来自「利用当前管理信息系统科学的、实用的理论」· Java 代码 · 共 62 行
JAVA
62 行
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 + =
减小字号Ctrl + -
显示快捷键?