struts2框架中配置文件加载顺序
顺序 | 配置文件名 | 所在位置 | 说明 |
---|---|---|---|
1 | default.properties | struts2-core.jar\org\apache\struts2 | 不能修改 |
2 | struts-default.xml | struts2-core.jar | 不可修改 |
3 | strtuts-plugin.xml | 在struts2提供的插件jar包中 | 不可修改 |
4 | struts.xml | 我们的应用中 | 可修改 |
5 | struts.properties | 我们的应用中 | 可修改 |
6 | web.xml | 我们的应用中 | 可修改,给过滤器配置参数 |
虽然框架源码中的配置文件无法更改 但可以更改应用中的配置文件 由于加载顺序靠后 应用中的配置文件可以覆盖配置内容
更改访问路径的后缀名
在default.properties中后缀名struts.action.extension 被规定为action或者为空
struts.action.extension=action,,
更改方法:
-
在struts.xml的配置文件中添加
<constant name="struts.action.extension" value="更改值"></constant>
-
在src下创建struts.properties添加
struts.action.extension=更改值
-
在web.xml中配置
<filter> <init-param> <param-name>struts.action.extension</param-name> <param-value>规定值</param-value> </init-param> </filter>
更改开发者模式
更改为开发者模式后 可以看到更多报错信息
如图:
在default.properties中后缀名struts.devMode 默认为关闭
struts.devMode=false
可以在struts.xml中更改为true
<constant name="struts.devMode" value="true"></constant>