1 通过filter启用struts2
<filter>
<filter-name>struts2Filter</filter-name>
<filter-class>
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2Filter</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>
2 ActionContextCleanUp配置
AcitonContextCleanUp负责清空ActionContext的内容,如果不配置这个filter由Filterdispatcher每一次调用清空,可能照成要使用ActionContext时候已经被清空了,所以把清空工作交给ActionContextCleanUp统一处理,避免上述情况的发生。
<filter>
<filter-name>cleanup</filter-name>
<filter-class>org.apache.Struts2.dispatcher.ActionContextCleanUp</filter-class>
</filter>
<filter-mapping>
<filter-name>cleanup</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>