Today,script an example for hands-on struts.
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
version="2.4"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<servlet>
<servlet-name>action</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>
<init-param>
<param-name>debug</param-name>
<param-value>3</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>3</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet>
<servlet-name>SelectCityServlet</servlet-name>
<servlet-class>com.aaron.servlet.SelectCityServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>SelectCityServlet</servlet-name>
<url-pattern>/servlet/SelectCityServlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
</web-app>
struts-conf.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd">
<struts-config>
<data-sources />
<form-beans >
<form-bean name="loginForm" type="com.aaron.struts.form.LoginForm" />
</form-beans>
<global-exceptions />
<global-forwards >
<forward name="success" path="/success.jsp" />
</global-forwards>
<action-mappings >
<action
attribute="loginForm"
input="/input.jsp"
name="loginForm"
path="/login"
scope="request"
type="com.aaron.struts.action.LoginAction">
<forward name="success" path="/success.jsp" />
</action>
<!-- Struts Ajax -->
<action
type="com.aaron.struts.action.CheckAction"
scope="request"
path="/check">
<forward name="success" path="/struts-ajax.jsp"/>
</action>
</action-mappings>
<message-resources parameter="com.aaron.struts.ApplicationResources" />
</struts-config>