Struts
核心代碼如下:
congratulations!${user
package org
import javax
import org
import org
import com
public class RegisterAction extends ActionSupport {
private User user;
@Override
public String execute() throws Exception {
if(!(user
this
return
}
else
{
HttpServletRequest request = ServletActionContext
request
return SUCCESS;
}
}
public User getUser() {
return user;
}
public void setUser(User user) {
this
}
}
package org
import java
public class User {
private String userName;
private String password;
private String rePassword;
private Integer age;
private Date birthday;
public Integer getAge() {
return age;
}
public void setAge(Integer age) {
this
}
public Date getBirthday() {
return birthday;
}
public void setBirthday(Date birthday) {
this
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this
}
public String getRePassword() {
return rePassword;
}
public void setRePassword(String rePassword) {
this
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this
}
}
< VALIDATORS>
< !
< FIELD
< !
< PARAM name=
< !
< MESSAGE>用戶名不能為空
< /FIELD
< !
< FIELD
< PARAM name=
< MESSAGE>用戶名長度應在
true
< FIELD
< MESSAGE>密碼不能為空
< /FIELD
< FIELD
< PARAM name=
< /FIELD
< /FIELD>
< FIELD
< PARAM name=
< PARAM name=
< MESSAGE>年齡應在
< /FIELD
< !
< FIELD
< PARAM name=
< PARAM name=
< MESSAGE>出生日期應在
< /FIELD>
< /VALIDATORS>
< STRUTS>
< CONSTANT name=
< RESULT name=
< RESULT name=
< /ACTION>
< /PACKAGE>
< /STRUTS>
< ?XML:NAMESPACE PREFIX = [default] < web
xmlns:xsi=
xsi:schemaLocation=
< filter>
< filter
org
< filter>
< filter
org
< filter
< filter
/*
< filter
< filter
< url
< welcome
< welcome
< /welcome
< /web
至此
From:http://tw.wingwit.com/Article/program/Java/ky/201311/28393.html