一 导包
二 xml配置
<filter>
<filter-name>Struts2</filter-name>
<!--这个也行 org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter-->
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>Struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
三 创建Action
import com.opensymphony.xwork2.ActionSupport;
public class ActionTest extends ActionSupport{
@Override
public String execute() throws Exception {
return "execute";
}
四struts.xml配置
<struts>
<package name="demo" extends="struts-default">
<action name="testdemo" class="test.ActionTest" method="execute">
<result name="execute">/test.jsp</result>
</action>
</package>
</struts>
五jsp
</head>
<body>
<h2>欢迎光临</h2>
</body>
</html>
在浏览器输入
http://localhost:8080/SpringDome/testdemo