Struts2配置文件的加载
1.加载时机
当应用被tomcat加载的时候,struts2的配置文件就已经被加载过了。
2.加载顺序
| 顺序 |
配置文件名 |
所在位置 |
说明 |
| 1 |
default.properties (定义了许多常量) |
struts2-core-2.3.15.3.jar\org\apache\struts2 |
不能修改 |
| 2 |
struts-default.xml |
struts2-core-2.3.15.3.jar |
不能修改 |
| 3 |
strtuts-plugin.xml |
在struts2提供的插件jar包中 |
不能修改 |
| 4 |
struts.xml |
我们的应用中 |
我们修改的:按照规范自定义 |
| 5 |
struts.properties |
我们的应用中 |
我们修改的:按照规范自定义 |
| 6 |
web.xml |
我们的应用中 |
我们修改的,可以给过滤器配置参数 |
注:当多个配置文件中,有相同的参数,后面的会把前面的值给覆盖了。常量的xml标签<constant name="" class=""><constant />
3.常用常量设定
default.properties定义常量,体现形式都是key=value。所有的struts2应用都会用到这些常量
| 常量名 | 常量值 | 说明 |
|
struts.i18n.encoding |
UTF-8 |
应用中使用的编码,国际化 |
|
struts.objectFactory.spring.autoWire |
name |
和spring框架整合有关,自动装配问题 |
|
struts.multipart.parser |
jakarta |
指定文件上传用的组件 |
|
struts.multipart.maxSize |
2097152 |
文件上传总文件大小限制:2M |
|
struts.action.extension |
action,, |
能进入Struts2框架内部的url地址后缀名。多个值用逗号分隔 |
|
struts.enable.DynamicMethodInvocation |
false |
是否允许动态方法调用 |
|
struts.devMode |
false |
是否是开发模式。开发模式:改了配置文件,不需要重启。输出更多的错误信息。开发阶段建议为true。 |
|
struts.ui.theme |
xhtml |
页面展示用的主题 |

浙公网安备 33010602011771号