?? submitform.java
字號:
package submit;import javax.servlet.http.HttpServletRequest;import org.apache.struts.action.*;public final class SubmitForm extends ActionForm { /* Getter and Setter methods of properties */ /* Getter and Setter methods of Last Name property */ private String lastName = "Your last name"; // default value public String getLastName() { return (this.lastName); } public void setLastName(String lastName) { this.lastName = lastName; } /* Getter and Setter methods of Address property */ private String address = null; public String getAddress() { return (this.address); } public void setAddress(String address) { this.address = address; } /* Getter and Setter methods of Sex property */ private String sex = null; public String getSex() { return (this.sex); } public void setSex(String sex) { this.sex = sex; } /* Getter and Setter methods of Married status property */ private String married = null; public String getMarried() { return (this.married); } public void setMarried(String married) { this.married = married; } /* Getter and Setter methods of Age property */ private String age = null; public String getAge() { return (this.age); } public void setAge(String age) { this.age = age; } /* Input validation */ public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { // Log the forms data servlet.log("Lastname:" + lastName); servlet.log("Address:" + address); servlet.log("Sex:" + sex); servlet.log("Married:" + married); servlet.log("Age:" + age); // Check for mandatory data ActionErrors errors = new ActionErrors(); if (lastName == null || lastName.equals("")) { errors.add("Last Name", new ActionError("error.lastName")); } if (address == null || address.equals("")) { errors.add("Address", new ActionError("error.address")); } if (sex == null || sex.equals("")) { errors.add("Sex", new ActionError("error.sex")); } if (age == null || age.equals("")) { errors.add("Age", new ActionError("error.age")); } return errors; }}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -