日期:2014-05-19  浏览次数:20674 次

struts2输入校验得不出结果 求指点
输入界面:<%@ page language="java" import="java.util.*" pageEncoding="GB18030"%>  
<%  
String path = request.getContextPath();  
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";  
%>  
<%@ taglib prefix="s" uri="/struts-tags"%>  
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">  
<html>  
  <head>  
  <base href="<%=basePath%>">  
   
  <title>My JSP 'index.jsp' starting page</title>  
  <!--  
  <link rel="stylesheet" type="text/css" href="styles.css">  
  -->  
  </head>  
   
  <body>  
  <s:form action="testValidate" method="post">  
  <s:textfield name="username" label="username"></s:textfield>  
  <s:password name="password" label="password"></s:password>  
  <s:password name="repassword" label="repassword"></s:password>  
  <s:textfield name="age" label="age"></s:textfield>  
  <s:textfield name="birthday" label="birthday"></s:textfield>  
  <s:textfield name="graduation" label="graduation"></s:textfield>  
   
  <s:submit name="submit"></s:submit>  
  <s:reset name="reset"></s:reset>  
  </s:form>  
  
  </body>  
</html>  


action处理代码:
package struts2;

import java.util.Calendar;  
import java.util.Date;  
import com.opensymphony.xwork2.ActionSupport;  
  
public class ValidateTest extends ActionSupport  
 
{  
  private String username;  
  private String password;  
  private String repassword;  
  private int age;  
  private Date birthday;  
  private Date graduation;  
   
  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 String getRepassword() {  
  return repassword;  
  }  
  public void setRepassword(String repassword) {  
  this.repassword = repassword;  
  }  
  public int getAge() {  
  return age;