日期:2014-05-17 浏览次数:20667 次
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ page isELIgnored="false"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<body>
<s:text name="infoText"></s:text>
<s:property value="% { getText('infoText')}"/>
<br />
<s:text name="infoTextParam">
<s:param>我是参数1</s:param>
<s:param>我是参数2</s:param>
</s:text>
<br />
<s:form action="register" method="post">
账号:<s:textfield name="username"></s:textfield>${errors.username[0]}
<br/>
密码:<s:textfield name="password"></s:textfield>${errors.password[0]}
<br/>
年龄:<s:textfield name="age"></s:textfield>${errors.age[0]}
<br/>
身高:<s:textfield name="height"></s:textfield>${errors.height[0]}
<br/>
测试:${errors.infoTextParamValueFromAction[0]}
<br/>
<s:submit value="提交"></s:submit>
</s:form>
</body>
</html>
package controller;
import java.util.ArrayList;
import java.util.List;
import com.opensymphony.xwork2.ActionSupport;
public class Register extends ActionSupport{
private String username;
private String password;
private Integer age;
private Double height;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public Integer getAge() {
return age;
}
public void setAge(Integer age) {
this.age = age;
}
public Double getHeight() {
return height;
}
public void setHeight(Double height) {
this.height = height;
}
@Override
public void validate(){