Struts2 initial experience

Source: Internet
Author: User

Sturts is an elegant and scalable framework. It is a new product jointly developed by the Struts development team and the WebWord team. The new version of Struts2 is easier to use and is closer to the concept pursued by Struts. The improvement in efficiency in development, deployment, and maintenance will undoubtedly allow it to continue to write the glory of Struts1. In the face of some big temptations, let's join in the world of Struts2!

1. Download Struts2 resources.

Official website address: http://www.apache.org/

After downloading and decompressing the package, you can see the following content:

Apps: Official Struts2 application example

Docs: Struts2 documentation

Lib: Struts2 release package and dependency package

Src: Struts2 source code

The remaining part is the License Agreement and Declaration of Struts2 and its dependent packages.

2. Add Struts2 to the Project

Create a java wed project. Select the five jar files under lib in the Struts2 resource, struts2-core-2.3.15.1.jar, xwork-core-2.3.15.1.jar, ognl-3.0.6.jar, freemarker-2.3.19.jar, add to project. Copy the jar package to the webContent \ web-inf \ lib folder under the project.

Note: different versions of struts2 need to add packages are also different, here we recommend that the Struts2 Resources in the apps directory under the struts2-blank.war project decompression. Open the decompressed folder. Add all jar packages under \ web-inf \ lib to the project. For example:

3. Create a test JSP page hellostruts2.jsp

Test Struts2

                                                                  message="hello"+          "hellostruts2"                                 .name =                                 .message =  }

5. Modify the project's web. xml configuration file.

     HelloStruts        index.html     index.htm     index.jsp     default.html     default.htm     default.jsp                     struts2         org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter                        struts2         /*         

6. Create the struts. xml file under the src directory. The content is as follows:

                                                                                hellostruts2.jsp                          

Last step: Compile and deploy the server and access hellostruts2.jsp.

After the form is submitted:

 

 

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.