📄 registerform.java
字号:
package struts.form;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
public class RegisterForm extends ActionForm {
// --------------------------------------------------------- Instance Variables
private String uid;
private String pwd1;
private String pwd2;
private String question;
private String answer;
private String rname;
private String sex;
private String city;
private String address;
private String email;
private String state;
private String province;
private String postcode;
private String tel;
private String mobile;
private String fax;
private String company;
private String homepage;
// --------------------------------------------------------- Methods
public ActionErrors validate(
ActionMapping mapping,
HttpServletRequest request) {
ActionErrors errors = new ActionErrors();
if (uid== null || uid.trim().equals("")) {
errors.add("uid", new ActionError("error.uid"));
}
if (pwd1 == null || pwd1.trim().equals("")) {
errors.add("pwd1", new ActionError("error.pwd1"));
}
if (pwd2 == null || pwd2.trim().equals("")) {
errors.add("pwd2", new ActionError("error.pwd1"));
}
if(!pwd1.equals(pwd2)){
errors.add("pwd",new ActionError("error.pwd"));
}
if (question == null ||question.trim().equals("")) {
errors.add("question", new ActionError("error.question"));
}
if (answer == null ||answer.trim().equals("")) {
errors.add("answer", new ActionError("error.answer"));
}
//
if (rname == null ||rname.trim().equals("")||rname.length()>8) {
errors.add("rname", new ActionError("error.rname"));
}
if (sex == null ||sex.trim().equals("")) {
errors.add("sex", new ActionError("error.sex"));
}
if (province == null ||province.trim().equals("")) {
errors.add("province", new ActionError("error.province"));
}
if (city == null ||city.trim().equals("")) {
errors.add("city", new ActionError("error.city"));
}
if (homepage == null ||homepage.trim().equals("")) {
errors.add("homepage", new ActionError("error.homepage"));
}
if (company == null ||company.trim().equals("")) {
errors.add("company", new ActionError("error.company"));
}
if (postcode == null ||postcode.trim().equals("")) {
errors.add("postcode", new ActionError("error.postcode"));
}
if (address == null ||address.trim().equals("")) {
errors.add("address", new ActionError("error.address"));
}
if (tel == null ||tel.trim().equals("")) {
errors.add("tel", new ActionError("error.tel"));
}
if (email == null ||email.trim().equals("")) {
errors.add("notemail", new ActionError("error.notEmail"));
}
else if (email.indexOf("@")==-1||email.indexOf(".")==-1) {
errors.add("wrongemail", new ActionError("error.wrongEmail"));
}
return errors;
}
public void reset(ActionMapping mapping, HttpServletRequest request)
{
uid = "";
pwd1="";
pwd2="";
address = "";
email = "";
city="";
postcode="";
tel = "";
mobile="";
rname="";
question="";
answer="";
fax="";
company="";
homepage="";
}
public String getUid() {
return uid;
}
public void setUid(String uid) {
this.uid = uid;
}
public String getPwd1() {
return pwd1;
}
public void setPwd1(String pwd1) {
this.pwd1 = pwd1;
}
public String getPwd2() {
return pwd2;
}
public void setPwd2(String pwd2) {
this.pwd2 = pwd2;
}
public String getQuestion() {
return question;
}
public void setQuestion(String question) {
this.question = question;
}
public String getAnswer() {
return answer;
}
public void setAnswer(String answer) {
this.answer = answer;
}
public String getRname() {
return rname;
}
public void setRname(String rname) {
this.rname = rname;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
//
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getTel() {
return tel;
}
public void setTel(String tel) {
this.tel = tel;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getPostcode() {
return postcode;
}
public void setPostcode(String postcode) {
this.postcode = postcode;
}
public String getState(){
return state;
}
public void setState(String state){
this.state=state;
}
public String getProvince(){
return province;
}
public void setProvince(String province){
this.province=province;
}
public String getMobile() {
return mobile;
}
public void setMobile(String mobile) {
this.mobile = mobile;
}
public String getFax(){
return fax;
}
public void setFax(String fax){
this.fax=fax;
}
public String getCompany(){
return company;
}
public void setCompany(String company){
this.company=company;
}
public String getHomepage(){
return homepage;
}
public void setHomepage(String homepage){
this.homepage=homepage;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -