📄 employeeform.java
字号:
package edu.reumann;import org.apache.struts.action.ActionForm;import org.apache.struts.action.ActionMapping;import org.apache.struts.action.ActionErrors;import org.apache.struts.action.ActionError; import javax.servlet.http.HttpServletRequest; public class EmployeeForm extends ActionForm { private String name; private String age; private String department; public void setName(String name) { this.name = name; } public void setAge(String age) { this.age = age; } public void setDepartment(String department) { this.department = department; } public String getName() { return name; } public String getAge() { return age; } public String getDepartment() { return department; } public ActionErrors validate( ActionMapping mapping, HttpServletRequest request ) { ActionErrors errors = new ActionErrors(); if ( getName() == null || getName().length() < 1 ) { errors.add("name",new ActionError("error.name.required")); } if ( getAge() == null || getAge().length() < 1 ) { errors.add("age",new ActionError("error.age.required")); } else { try { Integer.parseInt( getAge() ); } catch( NumberFormatException ne ) { errors.add("age",new ActionError("error.age.integer")); } } return errors; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -