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: