Struts2学习札记三-Struts2中常量的配置及Struts2搜索常量的顺序

Struts2学习笔记三-----Struts2中常量的配置及Struts2搜索常量的顺序

Struts中可以在以下文件中配置常量:

default.properties文件(这里有很多常量)

struts-default.xml

struts-plugin.xml

struts.xml

struts.properties(为了与webwork向后兼容而提供)

web.xml

struts2加载常量的搜索顺序如下,后面的设置可以覆盖前面的设置:下面介绍两种配置方法

 

例如:

 在struts.xml文件中配置:

   <constant name="struts.action.extension" value="do,"/>

 web.xml文件中也配置struts.action.extension常量:

   <filter>

.....

<init-param>

<param-name>struts.action.extension</param-name>

<param-value>zzm</param-value>

</init-param>

   </filter>

   这样后缀名就改成了.zzm就不是.do

<!--EndFragment-->