📄 loginform.java
字号:
package user;
import javax.servlet.http.HttpSession;
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 username;
private String password;
private String code;
public String getUsername() {
return username;
}
public void setUsername(String name) {
username = name;
}
public void setPassword(String psw) {
password = psw;
}
public String getPassword() {
return password;
}
public void setCode(String code) {
this.code = code;
}
public String getCode() {
return code;
}
public ActionErrors validate(ActionMapping map, HttpServletRequest request) {
ActionErrors errors=new ActionErrors ();
HttpSession session=request.getSession();
String code1=(String)session.getAttribute("code");
if(!code.equals(code1)||code.length()==0){
ActionError errorcode=new ActionError("error.code");
errors.add("code",errorcode);
}
if(username==null||username.length()==0){
ActionError err1= new ActionError ("error.username");
errors.add("username",err1);
}
if(password==null||password.length()<4){
ActionError err2= new ActionError ("error.password");
errors.add("password",err2);
}
return errors;
}
public void reset(ActionMapping actionMapping, HttpServletRequest httpServletRequest) {
username = null;
password = null;
code = null;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -