␡
- Using the Struts Framework to Develop a Message Board--Part 4: Developing the Controller for the Application
- Creating the Web.xml Configuration File
- Deploying the Application
Like this article? We recommend
Creating the Web.xml Configuration File
The final step is to declare and configure the ActionServlet to use the internalized resources, ApplicationResources.properties, in the servlet tag, as shown in Listing 3. In the servlet-mapping tag, we specify that ActionServlet is mapped to all URIs with a .do extension. You must also declare the Struts tag library.
Listing 3 Web.xmlThe Configuration File for the Web Application
<?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" "">http://java.sun.com/j2ee/dtds/web-app_2_2.dtd"> <web-app> <!-- Action Servlet Configuration --> <servlet> <servlet-name>action</servlet-name> <servlet-class>org.apache.struts.action.ActionServlet</servlet-class> <init-param> <param-name>application</param-name> <param-value>ApplicationResources</param-value> </init-param> <init-param> <param-name>config</param-name> <param-value>/WEB-INF/action.xml</param-value> </init-param> <init-param> <param-name>debug</param-name> <param-value>2</param-value> </init-param> <init-param> <param-name>detail</param-name> <param-value>2</param-value> </init-param> <load-on-startup>2</load-on-startup> </servlet> <!-- Action Servlet Mapping --> <servlet-mapping> <servlet-name>action</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping> <!-- The Welcome File List --> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <!-- Struts Tag Library Descriptor --> <taglib> <taglib-uri>/WEB-INF/struts.tld</taglib-uri> <taglib-location>/WEB-INF/struts.tld</taglib-location> </taglib> </web-app>