日期:2014-05-20 浏览次数:20757 次
<?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <filter> <filter-name>struts2</filter-name> <filter-class> org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter </filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> </web-app>
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> <package name="reg" extends="struts-default"> <action name="register" class="com.ac.action.RegisterAction" > <result type="success">/succ.jsp</result> <result type="failure">/fail.jsp</result> </action> </package> </struts>
package com.ac.action; import com.opensymphony.xwork2.ActionSupport; public class RegisterAction extends ActionSupport { private String username; private String password; private String password2; 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 getPassword2() { return password2; } public void setPassword2(String password2) { this.password2 = password2; } @Override public String execute() throws Exception { return "success"; } }
. . <Context path="/reg" docBase="E:\workspace\aaa\WebRoot" reloadable="true"> </Context> . .
<body> <form action="register.action" method="post"> <table border="0"> <tr> <td>用户名:</td> <td><input type="text" name="username" /></td> </tr> <tr> <td>密 码:</td> <td><input type="password" name="password" /></td> </tr> <tr> <td>重复密码:</td> <td><input type="password" name="password2" /></td> </tr> <tr> <td colspan="2" align="center"><input type="submit" value="注册" /></td> </tr> </table> </form> </body>