📄 registerform.java
字号:
/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package edu.neu.sspp.struts.form;
import java.io.IOException;
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-06-2007
*
* XDoclet definition:
* @struts.form name="registerForm"
*/
public class RegisterForm extends ActionForm {
/*
* Generated fields
*/
/** sex property */
private String sex;
/** nick property */
private String nick;
/** email property */
private String email;
/** tel property */
private String tel;
/** name property */
private String name;
/** userName property */
private String userName;
/** rePassword property */
private String rePassword;
/** password property */
private String password;
/** class_ property */
private String class_;
private String intro;
private boolean isOpen;
/*
* Generated Methods
*/
/**
* Method validate
* @param mapping
* @param request
* @return ActionErrors
*/
public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
// TODO Auto-generated method stub
ActionErrors error = new ActionErrors();
if(password == null || password.equals("")) {
error.add("password", new ActionMessage("error.register.password.null"));
password = "";
rePassword = "";
}
if(!rePassword.equals(password)) {
error.add("rePassword", new ActionMessage("error.register.rePassword.wrong"));
password = "";
rePassword = "";
}
if(userName == null || userName.equals("")) {
error.add("userName", new ActionMessage("error.register.userName.null"));
password = "";
rePassword = "";
}
else if(!userNameRight()) {
error.add("userName", new ActionMessage("error.register.userName.error"));
password = "";
rePassword = "";
}
if(nick == null || nick.equals("")) {
error.add("nick", new ActionMessage("error.register.nick.null"));
password = "";
rePassword = "";
}
if(email == null || email.equals("")) {
error.add("email", new ActionMessage("error.register.email.null"));
password = "";
rePassword = "";
}
else if(!email.contains("@") || !email.contains(".")) {
error.add("email", new ActionMessage("error.register.email.error"));
password = "";
rePassword = "";
}
try {
convertToUTF();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if(intro.length() > 200) {
error.add("intro", new ActionMessage("error.register.intro.error"));
password = "";
rePassword = "";
}
return error;
}
/**
* Method reset
* @param mapping
* @param request
*/
public void reset(ActionMapping mapping, HttpServletRequest request) {
// TODO Auto-generated method stub
}
/**
* Returns the sex.
* @return String
*/
public String getSex() {
return sex;
}
/**
* Set the sex.
* @param sex The sex to set
*/
public void setSex(String sex) {
this.sex = sex;
}
/**
* Returns the nick.
* @return String
*/
public String getNick() {
return nick;
}
/**
* Set the nick.
* @param nick The nick to set
*/
public void setNick(String nick) {
this.nick = nick;
}
/**
* Returns the email.
* @return String
*/
public String getEmail() {
return email;
}
/**
* Set the email.
* @param email The email to set
*/
public void setEmail(String email) {
this.email = email;
}
/**
* Returns the tel.
* @return String
*/
public String getTel() {
return tel;
}
/**
* Set the tel.
* @param tel The tel to set
*/
public void setTel(String tel) {
this.tel = tel;
}
/**
* Returns the name.
* @return String
*/
public String getName() {
return name;
}
/**
* Set the name.
* @param name The name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* Returns the userName.
* @return String
*/
public String getUserName() {
return userName;
}
/**
* Set the userName.
* @param userName The userName to set
*/
public void setUserName(String userName) {
this.userName = userName;
}
/**
* Returns the rePassword.
* @return String
*/
public String getRePassword() {
return rePassword;
}
/**
* Set the rePassword.
* @param rePassword The rePassword to set
*/
public void setRePassword(String rePassword) {
this.rePassword = rePassword;
}
/**
* Returns the password.
* @return String
*/
public String getPassword() {
return password;
}
/**
* Set the password.
* @param password The password to set
*/
public void setPassword(String password) {
this.password = password;
}
/**
* Returns the class_.
* @return String
*/
public String getClass_() {
return class_;
}
/**
* Set the class_.
* @param class_ The class_ to set
*/
public void setClass_(String class_) {
this.class_ = class_;
}
public boolean getIsOpen() {
return isOpen;
}
public void setIsOpen(boolean isOpen) {
this.isOpen = isOpen;
}
private boolean userNameRight() {
for(int i = 0; i < userName.length(); i++) {
char c = userName.charAt(i);
if(!(c >= 'a' && c <= 'z'|| c >= 'A' && c <= 'Z'
|| c >= '0' && c <= '9' || c == '_'))
return false;
}
return true;
}
private void convertToUTF() throws IOException {
userName = new String(userName.getBytes("ISO-8859-1"), "UTF-8");
password = new String(password.getBytes("ISO-8859-1"), "UTF-8");
nick = new String(nick.getBytes("ISO-8859-1"), "UTF-8");
email = new String(email.getBytes("ISO-8859-1"), "UTF-8");
name = new String(name.getBytes("ISO-8859-1"), "UTF-8");
class_ = new String(class_.getBytes("ISO-8859-1"), "UTF-8");
tel = new String(tel.getBytes("ISO-8859-1"), "UTF-8");
intro = new String(intro.getBytes("ISO-8859-1"), "UTF-8");
}
public String getIntro() {
return intro;
}
public void setIntro(String intro) {
this.intro = intro;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -