`
yonghengmoming
  • 浏览: 47398 次
  • 性别: Icon_minigender_1
  • 来自: 福州
社区版块
存档分类
最新评论

struts.xml参数详解(留着自己看的)

 
阅读更多

 

参考自:http://www.cnblogs.com/it563/articles/1939927.html

  1. <?xml version="1.0" encoding="GBK"?>  
  2. <!-- 下面指定Struts 2.1配置文件的DTD信息 -->  
  3. <!DOCTYPE struts PUBLIC  
  4.         "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN"  
  5.         "http://struts.apache.org/dtds/struts-2.1.dtd">  
  6. <!-- struts是Struts 2配置文件的根元素 -->  
  7. <struts>  
  8.         <!-- 下面元素可以出现零次,也可以出现无数次 -->  
  9.         <constant name="" value="" />  
  10.         <!-- 下面元素可以出现零次,也可以出现无数次 -->  
  11.         <bean type="" name="" class="" scope="" static="" optional="" />  
  12.         <!-- 下面元素可以出现零次,也可以出现无数次 -->  
  13.         <include file="" />  
  14.         <!-- package元素是Struts配置文件的核心,该元素可以出现零次,或者无数次 -->  
  15.         <package name="必填的包名" extends="" namespace="" abstract=""  
  16.                 externalReferenceResolver>  
  17.                 <!-- 该元素可以出现,也可以不出现,最多出现一次 -->  
  18.                 <result-types>  
  19.                         <!-- 该元素必须出现,可以出现无数次-->  
  20.                         <result-type name="" class="" default="true|false">  
  21.                                 <!-- 下面元素可以出现零次,也可以无数次 -->  
  22.                                 <param name="参数名">参数值</param>*  
  23.                         </result-type>  
  24.                 </result-types>  
  25.                 <!-- 该元素可以出现,也可以不出现,最多出现一次 -->  
  26.                 <interceptors>  
  27.                         <!-- 该元素的interceptor元素和interceptor-stack至少出现其中之一,  
  28.                         也可以二者都出现 -->  
  29.                         <!-- 下面元素可以出现零次,也可以无数次 -->  
  30.                         <interceptor name="" class="">  
  31.                                 <!-- 下面元素可以出现零次,也可以无数次 -->  
  32.                                 <param name="参数名">参数值</param>*  
  33.                         </interceptor>  
  34.                         <!-- 下面元素可以出现零次,也可以无数次 -->  
  35.                         <interceptor-stack name="">  
  36.                                 <!-- 该元素必须出现,可以出现无数次-->  
  37.                                 <interceptor-ref name="">  
  38.                                         <!-- 下面元素可以出现零次,也可以无数次 -->  
  39.                                         <param name="参数名">参数值</param>*  
  40.                                 </interceptor-ref>  
  41.                         </interceptor-stack>  
  42.                 </interceptors>  
  43.                 <!-- 下面元素可以出现零次,也可以无数次 -->  
  44.                 <default-interceptor-ref name="">  
  45.                         <!-- 下面元素可以出现零次,也可以无数次 -->  
  46.                         <param name="参数名">参数值</param>  
  47.                 </default-interceptor-ref>  
  48.                 <!-- 下面元素可以出现零次,也可以无数次 -->  
  49.                 <default-action-ref name="">  
  50.                         <!-- 下面元素可以出现零次,也可以无数次 -->  
  51.                         <param name="参数名">参数值</param>*  
  52.                 </default-action-ref>?  
  53.                 <!-- 下面元素可以出现零次,也可以无数次 -->  
  54.                 <global-results>  
  55.                         <!-- 该元素必须出现,可以出现无数次-->  
  56.                         <result name="" type="">  
  57.                                 <!-- 该字符串内容可以出现零次或多次 -->  
  58.                                 映射资源  
  59.                                 <!-- 下面元素可以出现零次,也可以无数次 -->  
  60.                                 <param name="参数名">参数值</param>*  
  61.                         </result>  
  62.                 </global-results>  
  63.                 <!-- 下面元素可以出现零次,也可以无数次 -->  
  64.                 <global-exception-mappings>  
  65.                         <!-- 该元素必须出现,可以出现无数次-->  
  66.                         <exception-mapping name="" exception="" result="">  
  67.                                 异常处理资源  
  68.                                 <!-- 下面元素可以出现零次,也可以无数次 -->  
  69.                                 <param name="参数名">参数值</param>*  
  70.                         </exception-mapping>  
  71.                 </global-exception-mappings>  
  72.                 <action name="" class="" method="" converter="">  
  73.                         <!-- 下面元素可以出现零次,也可以无数次 -->  
  74.                         <param name="参数名">参数值</param>*  
  75.                         <!-- 下面元素可以出现零次,也可以无数次 -->  
  76.                         <result name="" type="">  
  77.                                 映射资源  
  78.                                 <!-- 下面元素可以出现零次,也可以无数次 -->  
  79.                                 <param name="参数名">参数值</param>*  
  80.                         </result>  
  81.                         <!-- 下面元素可以出现零次,也可以无数次 -->  
  82.                         <interceptor-ref name="">  
  83.                                 <!-- 下面元素可以出现零次,也可以无数次 -->  
  84.                                 <param name="参数名">参数值</param>*  
  85.                         </interceptor-ref>  
  86.                         <!-- 下面元素可以出现零次,也可以无数次 -->  
  87.                         <exception-mapping name="" exception="" result="">  
  88.                                 异常处理资源  
  89.                                 <!-- 下面元素可以出现零次,也可以无数次 -->  
  90.                                 <param name="参数名">参数值</param>*  
  91.                         </exception-mapping>  
  92.                 </action>  
  93.         </package>*  
  94.         <!-- unknown-handler-stack元素可出现零次或1次 -->  
  95.         <unknown-handler-stack>  
  96.                 <!-- unknown-handler-ref元素可出现零次或多次 -->  
  97.                 <unknown-handler-ref name=" ">...</unknown-handler-ref>*  
  98.         </unknown-handler-stack>?  
  99. <struts>  
 

2)  struts.properties 文件

这个文件是struts2框架的全局属性文件,也是自动加载的文件。该文件包含了系列的key-value对。该文件完全可以配置在struts.xml文件中,使用constant元素。下面是这个文件中一些常见的配置项及说明。

  1. ### 指定加载struts2配置文件管理器,默认为org.apache.struts2.config.DefaultConfiguration  
  2. ### 开发者可以自定义配置文件管理器,该类要实现Configuration接口,可以自动加载struts2配置文件。  
  3. struts.configuration=org.apache.struts2.config.DefaultConfiguration  
  4.   
  5. ### 设置默认的locale和字符编码  
  6. struts.locale=en_US  
  7. struts.i18n.encoding=UTF-8  
  8.   
  9.   
  10. ### 指定struts的工厂类  
  11. struts.objectFactory = spring  
  12.   
  13. ### 指定spring框架的装配模式  
  14. ### 装配方式有: name, type, auto, and constructor (name 是默认装配模式)  
  15. struts.objectFactory.spring.autoWire = name  
  16.   
  17. ### 该属性指定整合spring时,是否对bean进行缓存,值为true or false,默认为true.  
  18. struts.objectFactory.spring.useClassCache = true  
  19.   
  20. ### 指定类型检查  
  21. #struts.objectTypeDeterminer = tiger  
  22. #struts.objectTypeDeterminer = notiger  
  23.   
  24. ### 该属性指定处理 MIME-type multipart/form-data,文件上传  
  25. struts.multipart.parser=cos  
  26. struts.multipart.parser=pell  
  27. struts.multipart.parser=jakarta  
  28. # 指定上传文件时的临时目录,默认使用 javax.servlet.context.tempdir   
  29. strutsstruts.multipart.saveDir=  
  30. struts.multipart.maxSize=2097152  
  31.   
  32. ### 加载自定义属性文件 (不要改写struts.properties!)  
  33. struts.custom.properties=application,org/apache/struts2/extension/custom  
  34.   
  35. ### 指定请求url与action映射器,默认为org.apache.struts2.dispatcher.mapper.DefaultActionMapper  
  36. #struts.mapper.class=org.apache.struts2.dispatcher.mapper.DefaultActionMapper  
  37.   
  38. ### 指定action的后缀,默认为action  
  39. struts.action.extension=action  
  40.   
  41. ### 被 FilterDispatcher使用  
  42. ### 如果为 true 则通过jar文件提供静态内容服务.   
  43. ### 如果为 false 则静态内容必须位于 <context_path>/struts  
  44. struts.serve.static=true  
  45.   
  46. ### 被 FilterDispatcher使用  
  47. ### 指定浏览器是否缓存静态内容,测试阶段设置为false,发布阶段设置为true.  
  48. struts.serve.static.browserCache=true  
  49.   
  50. ### 设置是否支持动态方法调用,true为支持,false不支持.  
  51. struts.enable.DynamicMethodInvocation = true  
  52.   
  53. ### 设置是否可以在action中使用斜线,默认为false不可以,想使用需设置为true.  
  54. struts.enable.SlashesInActionNames = false  
  55.   
  56. ### 是否允许使用表达式语法,默认为true.  
  57. struts.tag.altSyntax=true  
  58.   
  59.   
  60. ### 设置当struts.xml文件改动时,是否重新加载.  
  61. ### - struts.configuration.xml.reload = true  
  62. ### 设置struts是否为开发模式,默认为false,测试阶段一般设为true.  
  63. struts.devMode = false  
  64.   
  65. ### 设置是否每次请求,都重新加载资源文件,默认值为false.  
  66. struts.i18n.reload=false  
  67.   
  68. ###标准的UI主题  
  69. ### 默认的UI主题为xhtml,可以为simple,xhtml或ajax  
  70. struts.ui.theme=xhtml  
  71. ###模板目录  
  72. struts.ui.templateDir=template  
  73. #设置模板类型. 可以为 ftl, vm, or jsp  
  74. struts.ui.templateSuffix=ftl  
  75.   
  76. ###定位velocity.properties 文件.  默认 velocity.properties  
  77. struts.velocity.configfile = velocity.properties  
  78.   
  79. ### 设置velocity的context.  
  80. struts.velocity.contexts =  
  81.   
  82. ### 定位toolbox.  
  83. struts.velocity.toolboxlocation=  
  84.   
  85. ### 指定web应用的端口.  
  86. struts.url.http.port = 80  
  87. ### 指定加密端口  
  88. struts.url.https.port = 443  
  89. ### 设置生成url时,是否包含参数.值可以为: none, get or all  
  90. struts.url.includeParams = get  
  91.   
  92. ### 设置要加载的国际化资源文件,以逗号分隔.  
  93. struts.custom.i18n.resources=testmessages,testmessages2  
  94.   
  95. ### 对于一些web应用服务器不能处理HttpServletRequest.getParameterMap()  
  96. ### 像 WebLogic, Orion, and OC4J等,须设置成true,默认为false.  
  97. struts.dispatcher.parametersWorkaround = false  
  98.   
  99. ### 指定freemarker管理器  
  100. #struts.freemarker.manager.classname=org.apache.struts2.views.freemarker.FreemarkerManager  
  101.   
  102. ### 设置是否对freemarker的模板设置缓存  
  103. ### 效果相当于把template拷贝到 WEB_APP/templates.  
  104. struts.freemarker.templatesCache=false  
  105.   
  106. ### 通常不需要修改此属性.  
  107. struts.freemarker.wrapper.altMap=true  
  108.   
  109. ### 指定xslt result是否使用样式表缓存.开发阶段设为true,发布阶段设为false.  
  110. struts.xslt.nocache=false  
  111.   
  112. ### 设置struts自动加载的文件列表.  
  113. strutsstruts.configuration.files=struts-default.xml,struts-plugin.xml,struts.xml  
  114.   
  115. ### 设定是否一直在最后一个slash之前的任何位置选定namespace.  
  116. struts.mapper.alwaysSelectFullNamespace=false 
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics