struts2的配置文件

1.web.xml

2.struts.xml 主配置文件

   <Bean>配置(用来扩展struts2的功能)

           属性:class:全路径名

                    type:实现的接口

                    name:bean的名字,在具有相同type属性的bean中,改名字必须唯一

                    scope:bean的作用域;【default】,【singleton】,【request】,【session】,【thread】

                    static:是否静态注入,如果指定type,static就不能为true

 

 

 

3.struts.properties 属性文件(自定义放在src目录下可以用来冲第一属性)

4.struts-default.xml :struts2的默认配置文件  位置是:struts2-core-2.0.11.jar下面  里面主要配置了容器的很多bean,interceptor 以及struts-default包下的defaultStack等一些重要的东西以及特别有意义的 <default-                          interceptor-ref name="defaultStack"/>

5.struts-plugin.xml:struts2框架的插件文件 struts2框架的插件文件(没有用过,用到再总结)

6struts-default.xml 位置:struts2-core-2.0.11.jar->org.apache.struts2->static下,是一个只读文件文件

     这个文件中有一句特别重要的话:        Struts default properties(can be overridden by a struts.properties file in the root of the classpath)  翻译过来就是他是struts的默认属性的配置,如果要对那些属性重新定义可以再classpath下建立一个struts.properties来进行那些属性的值得覆盖(从这一段文字可以看出虽然可以再struts.xml中重新定义属性,但是官方更加推荐我们用这种方法来做

### This can be used to set your default locale and encoding scheme  可以用来设置默认时区或者编码
struts.locale=en_US
struts.i18n.encoding=UTF-8

上传的时候保存的路径大小设置

struts.multipart.saveDir=
struts.multipart.maxSize=2097152

访问Action扩展名的修改

### Used by the DefaultActionMapper
### You may provide a comma separated list, e.g. struts.action.extension=action,jnlp,do
struts.action.extension=action

 

是否让客户端缓存

### Used by FilterDispatcher
### This is good for development where one wants changes to the static content be
### fetch on each request.
### NOTE: This will only have effect if struts.serve.static=true
### If true -> Struts will write out header for static contents such that they will
### be cached by web browsers (using Date, Cache-Content, Pragma, Expires)
### headers).
### If false -> Struts will write out header for static contents such that they are
### NOT to be cached by web browser (using Cache-Content, Pragma, Expires
### headers)
struts.serve.static.browserCache=true   

最佳实践:开发阶段最好是设置为false;部署阶段设置为true

 是否每次请求都要对国际化资源文件进行加载

### when set to true, resource bundles will be reloaded on _every_ request.
### this is good during development, but should never be used in production
struts.i18n.reload=false

 官方建议:最佳实践,开发阶段设置为true,产品阶段设置为true

 

上面的这些属性都可以进行覆盖

 

三分文件中的覆盖属性

     1.struts.xml中配置

     2.struts.properties中配置

     3.web.xml中配置

           <init-param>

             <param-name></param-name>

             <param-value></param-value>

            </init-param>

 优先级:web.xml<--struts.properties<--struts.xml<--struts-plugin.xml<--struts-default.xml

 

 

 

 

 

posted @ 2013-01-25 13:38  虎猫  阅读(178)  评论(0编辑  收藏  举报