1、写一个注册页面,把请求交给 struts处理
<form action="${pageContext.request.contextPath }/Register.do" method="post">
用户名:<input type="text" name="username"><br/>
密码:<input type="password" name="password"><br/>
邮箱:<input type="text" name="email"><br/>
<input type="submit" value="注册">
</form>
2、导入struts开发包,并在web.xml文件配置struts(ActionServlet)处理所有.do请求
<servlet>
<servlet-name>ActionServlet</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>ActionServlet</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
3、在web-inf目录中加入struts的配置文件:struts-config.xml,并配置struts收到请求后找RegisterAction处理,并配置在找RegisterAction处理请求之前,把数据封装到formbean中
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.3//EN"
"http://struts.apache.org/dtds/struts-config_1_3.dtd">
<struts-config>
<form-beans>
<form-bean name="UserFormBean" type="cn.itcast.web.formbean.UserFormbean"></form-bean>
</form-beans>
<!-- 配置struts收到请求后找一个action处理 -->
<action-mappings>
<action path="/Register" type="cn.itcast.web.action.RegisterAction" name="UserFormBean"></action>
</action-mappings>
</struts-config>
4、把封装数据formbean,以及处理请求的RegisterAction写出来