`

struts2 convention 配置

 
阅读更多
  1. <? xml   version = "1.0"   encoding = "UTF-8"   ?>   
  2. <!DOCTYPE struts PUBLIC   
  3.     "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"   
  4.     "http://struts.apache.org/dtds/struts-2.0.dtd" >   
  5.   
  6. < struts >   
  7.      <!--开发模式设置开始//-->   
  8.      <!--++++++++++++++++++++++++++++++++++++++++++++++++开发状态 -->   
  9.      < constant   name = "struts.devMode"   value = "true"   />   
  10.      <!-- 国际化资源重新加载  -->   
  11.      < constant   name = "struts.i18n.reload"   value = "true"   />   
  12.      <!-- 配置文件重新加载 -->   
  13.      < constant   name = "struts.configuration.xml.reload"   value = "true"   />   
  14.      <!-- convention类从新加载 -->   
  15.      < constant   name = "struts.convention.classes.reload"   value = "true"   />   
  16.      <!--++++++++++++++++++++++++++++++++++++++++++++++++开发模式结束 -->   
  17.      <!-- 主题 -->   
  18.      < constant   name = "struts.ui.theme"   value = "simple"   />   
  19.      <!-- 地区 -->   
  20.      < constant   name = "struts.locale"   value = "zh_CN"   />   
  21.      <!-- 国际化编码 -->   
  22.      < constant   name = "struts.i18n.encoding"   value = "UTF-8"   />   
  23.      <!--  扩展-->   
  24.      < constant   name = "struts.action.extension"   value = "action,do,jsp"   />   
  25.      <!-- 启用动态方法调用 -->   
  26.      < constant   name = "struts.enable.DynamicMethodInvocation"   value = "true"   />   
  27.      <!-- 设置Struts 2是否允许在Action名中使用斜线 -->   
  28.      < constant   name = "struts.enable.SlashesInActionNames"   value = "false"   />   
  29.      <!-- 结果资源所在路径 -->   
  30.      < constant   name = "struts.convention.result.path"   value = "/" />     
  31.      <!-- action后缀 -->   
  32.      < constant   name = "struts.convention.action.suffix"   value = "Action" />     
  33.      <!-- 名称首字母小写 -->   
  34.      < constant   name = "struts.convention.action.name.lowercase"   value = "true" />     
  35.      <!-- 分隔符 一个action名字的获取。比如为HelloWorldAction。按照配置,actionName为hello_world。 -->   
  36.      < constant   name = "struts.convention.action.name.separator"   value = "_" />     
  37.      <!-- 禁用扫描 -->   
  38.      < constant   name = "struts.convention.action.disableScanning"   value = "false" />     
  39.      <!-- 默认包 -->   
  40.      < constant   name = "struts.convention.default.parent.package"   value = "default" />     
  41.      <!--确定搜索包的路径。只要是结尾为action的包都要搜索。basePackage按照默认不用配置,如果配置,只会找以此配置开头的包。locators及locators.basePackage都是一组以逗号分割的字符串。 -->   
  42.      < constant   name = "struts.convention.package.locators"   value = "actions" />     
  43.      <!-- 禁用包搜索 -->   
  44.      < constant   name = "struts.convention.package.locators.disable"   value = "false" />     
  45.      <!--  基于什么包  -->   
  46.      < constant   name = "struts.convention.package.locators.basePackage"   value = "com.sunflower.actions" />    
  47.      <!--  排除的包  -->   
  48.      < constant   name = "struts.convention.exclude.packages"   value = "org.apache.struts.*,org.apache.struts2.*,org.springframework.web.struts.*,org.springframework.web.struts2.*,org.hibernate.*" />   
  49.      <!-- 包含的包 -->   
  50.      <!-- 包括的jar,一般用于大型项目,其action一般打包成jar -->   
  51.      < constant   name = "struts.convention.action.includeJars"   value = ""   />   
  52.      <!-- 结果类型 -->   
  53.      < constant   name = "struts.convention.relative.result.types"   value = "dispatcher,freemarker" />     
  54.     <!--    
  55.      如果此值设为true,如果一个action的命名空间为/login,名称为HelloWorldAction。result返回值是success,默认会找到/WEB-INF/pages/login/hello_world.jsp(如果有hello_world_success.jsp就找这个文件,连接符“_”是在 < constant   name = "struts.convention.action.name.separator"   value = "_" /> 中配置的)。如果有一个action的result返回值是“error”,就会找/WEB-INF/pages /login/hello_world_error.jsp。    
  56.   
  57.       如果此值设为false,如果一个action的命名空间为/login,名称为HelloWorldAction。result返回值是success,默认会找到/WEB- INF/pages/login/hello_world/index.jsp(如果有success.jsp就找这个文件)。如果有一个action的result返回值是“error”,就会找/WEB-INF/pages /login/hello_world/error.jsp。    
  58.      -- >   
  59.      < constant   name = "struts.convention.result.flatLayout"   value = "true" />   
  60.      < constant   name = "struts.convention.action.mapAllMatches"   value = "false" />     
  61.      <!-- 检查是否实现action -->   
  62.      < constant   name = "struts.convention.action.checkImplementsAction"   value = "true" />   
  63.      < constant   name = "struts.mapper.alwaysSelectFullNamespace"   value = "false" />   
  64.      < constant   name = "struts.convention.redirect.to.slash"   value = "true" />   
  65.      < package   name = "default"   extends = "struts-default" >   
  66.          < interceptors >   
  67.              < interceptor-stack   name = "defaultStack" >   
  68.                  < interceptor-ref   name = "exception"   />   
  69.                  < interceptor-ref   name = "servletConfig"   />   
  70.                  < interceptor-ref   name = "actionMappingParams"   />   
  71.                  < interceptor-ref   name = "staticParams"   />   
  72.                  < interceptor-ref   name = "params"   />   
  73.              </ interceptor-stack >   
  74.          </ interceptors >   
  75.      </ package >   
  76. </ struts >   
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics