📄 debugloginactionform.java~35~
字号:
package gxaccp.t07.guoneng_wei.petclinicmanagesystem.beans;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionError;
public class DebugLoginActionForm
extends ActionForm {
private String password;
private String userName;
public String getPassword() {
return password;
}
public void setPassword(String password) {
if(password!=null)
this.password = password;
}
public void setUserName(String userName) {
if(userName!=null)
this.userName = userName;
}
public String getUserName() {
return userName;
}
public ActionErrors validate(ActionMapping actionMapping,
HttpServletRequest request) {
/** @todo: finish this method, this is just the skeleton.*/
String uName = request.getParameter("userName");
String pswd = request.getParameter("password");
boolean flag=false;
ActionErrors errors=new ActionErrors();
if (uName != null && !"".equals(uName)) {
errors.add("userNameState",new ActionError("用户名要填写"));
flag=true;
}
if ( pswd != null && !"".equals(pswd)) {
errors.add("userPasswordState",new ActionError("密码要填写"));
flag=true;
}
if(flag){
return errors;//验证不合格者,返回封装了错误信息的ActionErrors对象
}
return null;////验证合格者,返回null
}
public void reset(ActionMapping actionMapping,
HttpServletRequest servletRequest) {
password = "";
userName = "";
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -