ITeye博客

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

yonghengmoming · 2012-04-14 10:34 · struts · Web前端 · Markdown

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

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。