首页 > 其他 > 详细

Struts2框架的常量属性及包含其他配置文件

时间:2014-04-19 15:54:58      阅读:564      评论:0      收藏:0      [点我收藏+]

Struts2框架的常量是对整个Struts2应用起作用的。在struts2-core-2.1.8.1.jar下的org.apache.struts2包下有一个default.properties文件,该文件为Struts2的所有常量都指定了默认值,下面我们列出一些常见的:

struts.i18n.encoding:指定web应用的默认编码集。该常量的默认值为UTF-8。该常量对于处理中文请求参数特别有用,我们常将该常量设置为GBK或GB2312。

struts.objectFactory.spring.autoWire:

struts.multipart.parser:

struts.multipart.saveDir:

struts.multipart.maxSize:

struts.action.extension:

struts.enable.DynamicMethodInvocation:

struts.devMode:

struts.i18n.reload:

struts.ui.theme:

struts.configuration.xml.reload:

struts.custom.i18n.resources:

struts.ognl.allowStaticMethodAccess:

还有很多,这里不一一列举。

 

Struts2配置常量总共有3种方式:

1. 通过struts.properties文件:放在类路径下,框架会自动加载,在myeclipse中也就是src目录下。这种方式主要是兼容webwork,不推荐使用。

2. 通过web.xml文件:为<filter>元素添加<init-param>子元素,在<init-param>中使用<param-name>和<param-value>子元素。这种方式也不推荐使用。

3. 通过struts.xml文件:放在类路径下即可。

 

Struts2框架按照如下顺序加载struts2常量:

1. struts-default.xml:

2. struts-plugin.xml:

3. struts.xml:

4. struts.properties:

5. web.xml:

 

为了避免struts.xml文件过于庞大,提高struts.xml文件的可读性,我们可以将一个struts.xml文件分解成多个配置文件,然后在struts.xml中包含其他配置文件:

bubuko.com,布布扣
<struts>
    <include file="struts-part.xml"/>
    ......
</struts>
bubuko.com,布布扣

 

Struts2框架的常量属性及包含其他配置文件,布布扣,bubuko.com

Struts2框架的常量属性及包含其他配置文件

原文:http://www.cnblogs.com/hardworking-fish/p/3670448.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!