Struts2 framework construction

Source: Internet
Author: User

Use struts2 version: Struts-2.3.16.3: http://struts.apache.org/

1. Add the struts2 dependency Library to the WEB Project

Commons-fileupload-1.3.1.jar

Commons-io-2.2.jar

Commons-lang3-3.1.jar

Commons-logging-1.1.3.jar

Freemarker-2.3.19.jar

Javassist-3.11.0.GA.jar

Ognl-3.0.6.jar

Struts2-core-2.3.16.3.jar

Xwork-core-2.3.16.3.jar

If the struts2 version is different, the specific version of the jar package may be slightly different.

Decompress the struts2-blank.war file in the Struts-2.3.16.3 \ apps directory

There is a required jar package for struts2 in the WEB-INF \ lib directory, or you can import it all.

2. Add struts filter in Web. xml

<filter><filter-name>struts2</filter-name><filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class></filter><filter-mapping><filter-name>struts2</filter-name><url-pattern>/*</url-pattern></filter-mapping>

3. Add struts. xml under classpath

<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN""http://struts.apache.org/dtds/struts-2.0.dtd"><struts><package name="build" extends="struts-default"><action name="login" method="login" class="com.itmyhome.Login"><result name="success">index.jsp</result></action></package></struts>
4. login. Java

Package com. itmyhome; public class login {Public String login () {system. Out. println ("*** entered ***"); Return "success ";}}
V. index. jsp

<Body> 6. Deploy the project to Tomcat

Enter http: // localhost: 8080/struts_frame/login in the browser

If the following content is displayed during normal page Jump, The struts2 framework is successfully set up.


Framework Structure:


Download source code: uploaded to be displayed


Welcome to the Java technology exchange group: 74955800


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.