⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 submitform.java

📁 NetBeans进行基础Struts编程
💻 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 + -