文章只是做一个记录,以便日后查阅
本人技术有限,有误的地方请友善指出,谢谢,O(∩_∩)O~
1,新建一个web项目,其他的就不多说了
2,新建一个user libraries ,此处取名struts,导入需要的基础包
3,配置web.xml
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
4,添加action类
package action;
import com.opensymphony.xwork2.ActionSupport;
public class TestStrutsAction extends ActionSupport {
private static final long serialVersionUID = -5561563641398878951L;
public String execute() throws Exception {
System.out.println("run execute method.....");
return SUCCESS;
}
}
5,配置struts.xml【文件添加到src下面】
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
<constant name="struts.devMode" value="true" />
<package name="default" namespace="/" extends="struts-default">
<action name="index" class="action.TestStrutsAction">
<result name="success">index.jsp</result>
</action>
</package>
</struts>
6,展示一下最后的结构