常量配置

default.properties文件中定义了struts2框架常用常量 .

问题:我们怎样可以定义常量

1.可以在src下创建一个strtus.properties配置文件

2.可以在web.xml文件中配置

3.可以直接在strtus.xml文件中定义常量 (推荐)

<!-- 声明常量 -->
<!-- 可以帮我们解决post请求乱码问题 -->
<constant name="struts.i18n.encoding=UTF-8" value="UTF-8"></constant>       

<!-- 指定访问struts2框架的扩展名 -->
<constant name="struts.action.extension" value="action"></constant>            

<!-- 提供更加详细的报错信息,以及在struts.xml文件修改后不再需要重启服务器-->  
<constant name="struts.devMode" value="true"></constant> 

注意:后加载的配置文件中的常量会将先加载的常量覆盖




猜你喜欢

转载自blog.csdn.net/qq_33500554/article/details/80718620