📄 empform.java
字号:
/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package org.lxh.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;
/**
* MyEclipse Struts Creation date: 06-12-2007
*
* XDoclet definition:
*
* @struts.form name="empForm"
*/
public class EmpForm extends ActionForm {
/*
* Generated fields
*/
/** type property */
private String type;
/** eage property */
private String eage;
/** deptno property */
private String deptno;
/** esex property */
private String esex = "男";
/** ename property */
private String ename;
/** empno property */
private String empno;
/*
* Generated Methods
*/
/**
* Method validate
*
* @param mapping
* @param request
* @return ActionErrors
*/
public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
ActionErrors errors = new ActionErrors();
if ("0".equals(type)) {
// Type = 0 :表示全部查询或模糊查询,全不验证
} else if ("1".equals(type)) {
// Type = 1 :表示插入操作,验证姓名、年龄、年龄是否是数字、性别、所属的部门
if (this.ename == null || "".equals(this.ename)) {
errors.add("ename", new ActionMessage("null.emp.ename"));
}
if (this.eage == null || "".equals(this.eage)) {
errors.add("eage", new ActionMessage("null.emp.eage"));
} else {
// 验证是否是数字
// System.out.println("** "+this.eage.matches("\\d*"));
if (!this.eage.matches("\\d*")) {
errors.add("eage", new ActionMessage("err.emp.eage"));
}
}
if (this.deptno == null || "".equals(this.deptno)) {
errors.add("deptno", new ActionMessage("null.dept.deptno"));
}
} else if ("2".equals(type)) {
// Type = 2 :表示删除操作、按ID查询操作,则验证员工的编号
if (this.empno == null || "".equals(this.empno)) {
errors.add("empno", new ActionMessage("null.emp.empno"));
}
} else {
// Type = 3 : 表示更新操作,则验证员工的全部信息,包括姓名、年龄、年龄是否是数字、性别、所属的部门
if (this.empno == null || "".equals(this.empno)) {
errors.add("empno", new ActionMessage("null.emp.empno"));
}
if (this.ename == null || "".equals(this.ename)) {
errors.add("ename", new ActionMessage("null.emp.ename"));
}
if (this.eage == null || "".equals(this.eage)) {
errors.add("eage", new ActionMessage("null.emp.eage"));
} else {
// 验证是否是数字
if (!this.eage.matches("\\d*")) {
errors.add("eage", new ActionMessage("err.emp.eage"));
}
}
if (this.deptno == null || "".equals(this.deptno)) {
errors.add("deptno", new ActionMessage("null.dept.deptno"));
}
}
return errors;
}
/**
* Method reset
*
* @param mapping
* @param request
*/
public void reset(ActionMapping mapping, HttpServletRequest request) {
// TODO Auto-generated method stub
}
/**
* Returns the type.
*
* @return String
*/
public String getType() {
return type;
}
/**
* Set the type.
*
* @param type
* The type to set
*/
public void setType(String type) {
this.type = type;
}
/**
* Returns the eage.
*
* @return String
*/
public String getEage() {
return eage;
}
/**
* Set the eage.
*
* @param eage
* The eage to set
*/
public void setEage(String eage) {
this.eage = eage;
}
/**
* Returns the deptno.
*
* @return String
*/
public String getDeptno() {
return deptno;
}
/**
* Set the deptno.
*
* @param deptno
* The deptno to set
*/
public void setDeptno(String deptno) {
this.deptno = deptno;
}
/**
* Returns the esex.
*
* @return String
*/
public String getEsex() {
return esex;
}
/**
* Set the esex.
*
* @param esex
* The esex to set
*/
public void setEsex(String esex) {
this.esex = esex;
}
/**
* Returns the ename.
*
* @return String
*/
public String getEname() {
return ename;
}
/**
* Set the ename.
*
* @param ename
* The ename to set
*/
public void setEname(String ename) {
this.ename = ename;
}
/**
* Returns the empno.
*
* @return String
*/
public String getEmpno() {
return empno;
}
/**
* Set the empno.
*
* @param empno
* The empno to set
*/
public void setEmpno(String empno) {
this.empno = empno;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -