Building a Struts 2 working environment

Source: Internet
Author: User

The MyEclipse integrated development environment is used here.

(1) Installation MyEclipse 8.5

(2) Installation configuration Tomcat6.0

    1. Download apache-tomcat-6.0.18
    2. Start MyEclipse 8.5, click the window->preferences command, and select the myeclipse->servers->tomcat->tomcat6.x option, as shown in:

Click the browse button behind the Tomcat home directory to find the Tomcat folder you downloaded, and when the settings are complete, click the OK button.

(3) Create a simple Struts 2 program

    1. Create a Web project
    2. Add a struts jar package to a project

3. Create a struts. XML configuration file

      1. to make the modified code for the default Web. xml file, Web. XML is required, and the other configuration files are optional, which is the core configuration file that is used to deploy the entire project. For the Struts 2 framework, if you want to load the controller filterdispatcher, you need to configure Filterdispatcher
         
      2. Configure the Struts.xml file, which is a very important core profile in the Struts application, struts 2 framework controls when to process which program and how to handle it based on the Struts.xml configuration file
      • <?xml version= "1.0" encoding= "UTF-8"? ><! DOCTYPE struts Public "-//apache software foundation//dtd struts Configuration 2.1//en" "http://struts.apache.org/dtds/ Struts-2.1.dtd "><struts> <constant name=" Struts.devmode "value=" true "/> <package name=" struts2_ Ognl_demo "extends=" Struts-default "> <!--defining Interceptors--<interceptors> <interceptor name=" hell Oworld "class=" com. Helloworldinterceptor "/> </interceptors> <action name=" test "class=" com. Myaction "> <result>success.jsp</result> <!--action to reference interceptors--<in Terceptor-ref name= "HelloWorld"/> <interceptor-ref name= "Defaultstack"/> </action></p ackage></struts> 

        6. Create an action business controller

        7. Create a JSP view page

      • Summary:
      1. Load configuration required to join Struts 2 in Web. xml
      2. The Execute () method of the action is used to return a string

Building a Struts 2 working environment

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.