📄 adminform.java
字号:
package tarena.netctoss.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;
import tarena.netctoss.model.TAdmin;
public class AdminForm extends ActionForm {
private Integer[] ids;
private TAdmin admin;
@Override
public void reset(ActionMapping mapping, HttpServletRequest request) {
// TODO Auto-generated method stub
super.reset(mapping, request);
}
@Override
public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
// TODO Auto-generated method stub
ActionErrors errors = new ActionErrors();
String sign = request.getParameter("sign");
if(sign.equals("register") || sign.equals("modify") || sign.equals("self")){
String str = request.getParameter("loginName");
int n = str.length();
for(int i=0;i<n;i++){
char c = str.charAt(i);
if(!(c >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z' || c >= '0' && c <= '9' || c == '_')){
errors.add("message",new ActionMessage("管理员帐号输入有误(只限字母,数字,下划线)!"));
request.setAttribute("message", "管理员帐号输入有误(只限字母,数字,下划线)!");
return errors;
}
}
String str1 = request.getParameter("phone");
System.out.println(str1);
int n1 = str1.length();
for(int i=0;i<n1;i++){
char c = str1.charAt(i);
if(!(c >= '0' && c <= '9')){
errors.add("message",new ActionMessage("联系方式输入有误!请连续输入管理员电话(例:01062136369)"));
request.setAttribute("message", "联系方式输入有误!请连续输入管理员电话(例:01062136369)");
return errors;
}
}
if(!sign.equals("self")){
String[] str2 = request.getParameterValues("modules");
System.out.println(str2);
if(str2 == null){
errors.add("message",new ActionMessage("请选择管理员的操作权限"));
request.setAttribute("message", "请选择管理员的操作权限");
}
}
}
return errors;
}
public Integer[] getIds() {
return ids;
}
public void setIds(Integer[] ids) {
this.ids = ids;
}
public TAdmin getAdmin() {
return admin;
}
public void setAdmin(TAdmin admin) {
this.admin = admin;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -