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