📄 myinfoform.java
字号:
package com.opensource.blog.web.form;
import javax.servlet.http.*;
import org.apache.struts.action.*;
import org.apache.commons.lang.*;
import com.opensource.blog.comm.*;
public class MyInfoForm
extends ActionForm {
private String action;
private String address;
private int age;
private String city;
private int edulevel;
private String email;
private int face;
private int income;
private int industry;
private String mb;
private String nickname;
private int pro;
private int sex;
private String sign;
private int work;
public ActionErrors validate(ActionMapping actionMapping, HttpServletRequest httpServletRequest) {
ActionErrors errors = new ActionErrors();
httpServletRequest.setAttribute("ageValues", Constant.AGES);
httpServletRequest.setAttribute("proValues", Constant.PROS);
httpServletRequest.setAttribute("workValues", Constant.WORKS);
httpServletRequest.setAttribute("incomeValues", Constant.INCOMES);
httpServletRequest.setAttribute("sortValues", Constant.SORTS);
httpServletRequest.setAttribute("industryValues", Constant.INDUSTRYS);
httpServletRequest.setAttribute("edulevelValues", Constant.EDULEVELS);
httpServletRequest.setAttribute("faceValues", Constant.FACES);
if (StringUtils.isBlank(this.action)) {
this.action = "show";
}
if (this.action.equalsIgnoreCase("edit")) {
if (StringUtils.isBlank(this.nickname)) {
errors.add("error.nullerror", new ActionMessage("error.nullerror"));
}
if (BlogUtil.getStringLength(this.nickname) > 20) {
errors.add("error.reg.nickname", new ActionMessage("error.reg.nickname"));
}
if (age == 0) {
errors.add("error.reg.age", new ActionMessage("error.reg.age"));
}
if (pro == 0) {
errors.add("error.reg.pro", new ActionMessage("error.reg.pro"));
}
if (work == 0) {
errors.add("error.reg.work", new ActionMessage("error.reg.work"));
}
if (income == 0) {
errors.add("error.reg.income", new ActionMessage("error.reg.income"));
}
if (industry == 0) {
errors.add("error.reg.industry", new ActionMessage("error.reg.industry"));
}
if (edulevel == 0) {
errors.add("error.reg.edulevel", new ActionMessage("error.reg.edulevel"));
}
if (city == null) {
city = "";
}
if (mb == null) {
mb = "";
}
if (address == null) {
address = "";
}
}
return errors;
}
public void reset(ActionMapping actionMapping, HttpServletRequest servletRequest) {
}
public String getAction() {
return action;
}
public String getAddress() {
return address;
}
public int getAge() {
return age;
}
public String getCity() {
return city;
}
public int getEdulevel() {
return edulevel;
}
public String getEmail() {
return email;
}
public int getFace() {
return face;
}
public int getIncome() {
return income;
}
public int getIndustry() {
return industry;
}
public String getMb() {
return mb;
}
public String getNickname() {
return nickname;
}
public int getPro() {
return pro;
}
public int getSex() {
return sex;
}
public String getSign() {
return sign;
}
public int getWork() {
return work;
}
public void setAction(String action) {
this.action = action;
}
public void setAddress(String address) {
this.address = address;
}
public void setAge(int age) {
this.age = age;
}
public void setCity(String city) {
this.city = city;
}
public void setEdulevel(int edulevel) {
this.edulevel = edulevel;
}
public void setEmail(String email) {
this.email = email;
}
public void setFace(int face) {
this.face = face;
}
public void setIncome(int income) {
this.income = income;
}
public void setIndustry(int industry) {
this.industry = industry;
}
public void setMb(String mb) {
this.mb = mb;
}
public void setNickname(String nickname) {
this.nickname = nickname;
}
public void setPro(int pro) {
this.pro = pro;
}
public void setSex(int sex) {
this.sex = sex;
}
public void setSign(String sign) {
this.sign = sign;
}
public void setWork(int work) {
this.work = work;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -