📄 loginform.java
字号:
package com.wiely.struts.form;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
@SuppressWarnings("serial")
public class LoginForm extends ActionForm {
String username;
String password;
String repassword;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getRepassword() {
return repassword;
}
public void setRepassword(String repassword) {
this.repassword = repassword;
}
@Override
public void reset(ActionMapping mapping, HttpServletRequest request) {
this.username = null;
this.password = null;
this.repassword = null;
}
@SuppressWarnings("deprecation")
@Override
public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
ActionErrors errors = new ActionErrors();
if (getUsername().trim().equalsIgnoreCase("") || getUsername() == null) {
errors.add("username",
new ActionMessage("errors.username.required"));
}
if (!getPassword().trim().equals(getRepassword())) {
errors.add("repassword",
new ActionMessage("errors.repassword.same"));
}
if ((getPassword().length() < 3) || (getPassword().length() > 11)) {
errors.add("password", new ActionMessage("errors.password.length"));
}
return errors;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -