項目結(jié)構(gòu): 運行結(jié)果: 運行結(jié)果:注冊成功
============================================== /struts2_0200_validation/src/com/b510/register/action/RegistAction.java 1 package com.b510.register.action; 2 3 import com.opensymphony.xwork2.ActionSupport; 4 5 import java.util.Date; 6 7 /** 8 * 注冊信息Action 9 * 10 * @author Hongten 11 * 12 */ 13 public class RegistAction extends ActionSupport { 14 private static final long serialVersionUID = 1L; 15 16 /** 17 * 用戶名 18 */ 19 private String name; 20 /** 21 * 密碼 22 */ 23 private String password; 24 /** 25 * 確認密碼 26 */ 27 private String repassword; 28 /** 29 * 年齡 30 */ 31 private int age; 32 /** 33 * 工資 34 */ 35 private double salary; 36 /** 37 * 生日 38 */ 39 private Date birthday; 40 /** 41 * 郵箱 42 */ 43 private String email; 44 /** 45 * 個人主頁 46 */ 47 private String personPage; 48 49 public int getAge() { 50 return age; 51 } 52 53 public Date getBirthday() { 54 return birthday; 55 } 56 57 public String getEmail() { 58 return email; 59 } 60 61 public String getName() { 62 return name; 63 } 64 65 public String getPassword() { 66 return password; 67 } 68 69 public String getPersonPage() { 70 return personPage; 71 } 72 73 public String getRepassword() { 74 return repassword; 75 } 76 77 public double getSalary() { 78 return salary; 79 } 80 81 public void setAge(int age) { 82 this.age = age; 83 } 84 85 public void setBirthday(Date birthday) { 86 this.birthday = birthday; 87 } 88 89 public void setEmail(String email) { 90 this.email = email; 91 } 92 93 public void setName(String name) { 94 this.name = name; 95 } 96 97 public void setPassword(String password) { 98 this.password = password; 99 } 100 101 public void setPersonPage(String personPage) { 102 this.personPage = personPage; 103 } 104 105 public void setRepassword(String repassword) { 106 this.repassword = repassword; 107 } 108 109 public void setSalary(double salary) { 110 this.salary = salary; 111 } 112 113 } /struts2_0200_validation/src/com/b510/register/action/RegistAction-validation.xml 1 <?xml version="1.0" encoding="GBK"?> /struts2_0200_validation/src/struts-validation.xml 1 <?xml version="1.0" encoding="GBK"?> 2 <!DOCTYPE struts PUBLIC 3 "-//Apache Software Foundation//DTD Struts Configuration 2.1.7//EN" 4 "http://struts./dtds/struts-2.1.7.dtd"> 5 <struts> 6 <package name="hongtenRegister" extends="struts-default"> 7 <!-- 用戶注冊的Action --> 8 <action name="regist" class="com.b510.register.action.RegistAction"> 9 <!-- 類型轉(zhuǎn)換失敗、輸入校驗失敗,轉(zhuǎn)入該頁面 --> 10 <result name="input">/regist.jsp</result> 11 <result>/show.jsp</result> 12 </action> 13 <action name=""> 14 <result>.</result> 15 </action> 16 </package> 17 </struts> /struts2_0200_validation/src/struts.xml 1 <?xml version="1.0" encoding="GBK"?> /struts2_0200_validation/WebRoot/regist.jsp 1 <%@ page contentType="text/html; charset=GBK" language="java" errorPage="" %> 2 <%@taglib prefix="s" uri="/struts-tags"%> 3 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 4 "http://www./TR/xhtml1/DTD/xhtml1-transitional.dtd"> 5 <html xmlns="http://www./1999/xhtml"> 6 <head> 7 8 <title>請輸入您的注冊信息</title> 9 <s:head/> 10 11 </head> 12 13 <body> 14 <h2>請輸入您的注冊信息</h2> 15 <s:form action="regist"> 16 <s:textfield name="name" label="用戶名"/> 17 <s:password name="password" label="密碼"/> 18 <s:password name="repassword" label="確認密碼"/> 19 <s:textfield name="age" label="年齡"/> 20 <s:textfield name="salary" label="工資"/> 21 <s:textfield name="birthday" label="生日"/> 22 <s:textfield name="email" label="郵箱"/> 23 <s:textfield name="personPage" label="個人主頁"/> 24 <s:submit value="注冊"/> 25 </s:form> 26 </body> 27 </html> /struts2_0200_validation/WebRoot/show.jsp 1 <%@ page contentType="text/html; charset=GBK" language="java" errorPage="" %> |
|