1. In the/WEB-INF/lib directory, import the JAR file of struts1 (in the lib directory of struts1 );
2. Modify/WEB-INF/Web. XML (Deployment Manager for the entire web project) and set servlet to point it to the actionservlet (central controller) of struts1)
Web. XML code:
<? XML
Version = "1.0"
Encoding = "UTF-8"?>
- <Web-app
Xmlns = "http://java.sun.com/xml/ns/javaee"
Xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance"
Version = "2.5"
Xsi: schemalocation = "http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.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>
- <Load-on-startup> 0 </load-on-startup>
- </Servlet>
- <Servlet-mapping>
- <Servlet-Name> action </servlet-Name>
- <URL-pattern> *. DO </url-pattern>
- </Servlet-mapping>
- </Web-app>
If config is under the/WEB-INF by default and is named struts-config.xml, You can omit not to write
3. To the struts configuration file: struts-config.xml
For example:
1. <? XML version = "1.0" encoding = "UTF-8"?>
2. <! Doctype Struts-config public
"-// Apache Software Foundation // DTD struts configuration 1.1 // en"
Http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd>
3. <Struts-config>
4. <form-beans>
5. <form-bean name = "peopleform" type = "org. formbean. peopleactionform"> </form-bean>
6. </form-beans>
7. <action-mappings>
8. <action Path = "/People" name = "peopleform" Scope = "request"
Type = "org. Action. handlepeopleaction">
9. <forward name = "success" Path = "/list. jsp"> </forward>
10. <forward name = "fail" Path = "/fail. jsp"> </forward>
11. <forward name = "modify" Path = "/modify. jsp"> </forward>
12. </Action>
13. </Action-mappings>
14. <message-resources parameter = "messageresources"/> <! -- Use the required struts tag -->
15. </Struts-config>