struts2除了引入必要的包外,还要在web.xml里进行配置.
--------------------------配置filter-----------------------------------
<filter>
<filter-name>struts-cleanup</filter-name>
<filter-class>org.apache.struts2.dispatcher.ActionContextCleanUp</filter-class>
</filter>
<filter>
<filter-name>struts</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
-------------------------配置mapping--------------------------------
<filter-name>struts</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>struts-cleanup</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
使用地方的一些注意.
struts.xml需要放到项目的src下,否则如果没有配置好,当你运行到一个Action时,会提示没有找到该Action的mapping
也可以写多个stuts-qq.xml不同的配置文件,然后再struts.xml配置这些xml 文件,把struts.xml放到src下也可.
struts.xml是配置一些ACTION映射页面跳转之类的.
如果是ACTION类跳转到另一个ACTION类,则需要重定向.
<result name="success" type="redirect">/center!list.action</result>
center 另外ACTION对应的别名
在JSP页面上action="center!province_total.action" center对应映射类的名称,province_total则是该Action类的方法