1.先建立一个项目
2.在WebRoot中建立一个jsp,名为index.jsp,在里面写一句话
<body>
hello struts2 <br>
</body>
3.在后台写入代码
public class T {
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter f;
}
4.在struts.xml中写入
<constant name="struts.devMode" value="true" />
<package name="default" namespace="/" extends="struts-default">
<action name="hell">
<result>
/Hello.jsp
</result>
</action>
</package>
5.在web.xml中写入
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
注意:
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
这一句很重要哦,可以说起决定性作用,不要忘记哦