Struts1 setup steps (forgetful, just remind yourself)

Source: Internet
Author: User

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"?>

  1. <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">
  2. <Servlet>
  3. <Servlet-Name> action </servlet-Name>
  4. <Servlet-class> org. Apache. Struts. Action. actionservlet </servlet-class>
  5. <Init-param>
  6. <Param-Name> config </param-Name>
  7. <Param-value>/WEB-INF/struts-config.xml </param-value>
  8. </Init-param>
  9. <Load-on-startup> 0 </load-on-startup>
  10. </Servlet>
  11. <Servlet-mapping>
  12. <Servlet-Name> action </servlet-Name>
  13. <URL-pattern> *. DO </url-pattern>
  14. </Servlet-mapping>
  15. </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>

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.