代码改变世界,积累成就自己Struts 中的配置文件

Struts 中的配置文件:

文件

可选项

位置

用途

web.xml

no

/WEB-INF/

Web 部署描述符包含所有必需框架组件

struts.xml

yes

/WEB-INF/classes/

主要配置 , 包含结果 / 视图类型 ,操作映射、拦截器 , 等等

struts.properties

yes

/WEB-INF/classes/

框架属性

struts-default.xml

yes

/WEB-INF/lib/struts2-core.jar

缺省配置,由 Struts 提供

struts-default.vm

yes

/WEB-INF/classes/

默认的宏 velocity.properties 所引用

struts-plugin.xml

yes

At the root of a plugin JAR

可选插件配置文件,格式同 struts一样。

struts-plugin.xm

yes

/WEB-INF/classes/

覆盖默认的速度配置

 

 

一、 Web.xml:

Web.xml 文件大家应该很熟悉,因为每个 web 程序都会有这个文件,而 Struts2 在使用时,需要在这个文件中进行配置 FilterDispatcher, 该过滤器类初始化 Struts 框架和处理所有的要求。并且这个过滤器可以包含一些初始化参数等。

Xml代码   收藏代码
  1. <web-app id="WebApp_9" version="2.4"   
  2.     xmlns="http://java.sun.com/xml/ns/j2ee"   
  3.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   
  4.     xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">  
  5.   
  6.     <filter>  
  7.         <filter-name>struts2</filter-name>  
  8.         <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>  
  9.         <init-param>  
  10.             <param-name>actionPackages</param-name>  
  11.             <param-value>com.mycompany.myapp.actions</param-value>  
  12.         </init-param>  
  13.     </filter>  
  14.   
  15.     <filter-mapping>  
  16.         <filter-name>struts2</filter-name>  
  17.         <url-pattern>/*</url-pattern>  
  18.     </filter-mapping>  
  19.   
  20.     <!-- ... -->  
  21.   
  22. </web-app>  
 

 

而标签一般不需要在这里配置,因为标签已经包含在 struts-core.jar ,容器会自动找到它。如果配置,则方式如下:

Xml代码   收藏代码
  1.    <!-- ... -->  
  2.     </welcome-file-list>  
  3.   
  4.     <taglib>  
  5.        <taglib-uri>/s</taglib-uri>  
  6.        <taglib-location>/WEB-INF/struts-tags.tld</taglib-location>  
  7.     </taglib>  
  8. </web-app>  

 

二、 Struts.xml

 

管理元素:

1、 Constant 节点

通过在 struts.xml 中对 Constant 节点的配置来提供一种改变框架默认行为的机制:

设置文件上传大小限制(单位字节)

Xml代码   收藏代码
  1. <constant name="struts.multipart.maxSize" value="29661132" />  

允许开发模式以提供更方便的调试功能

Xml代码   收藏代码
  1. <constant name="struts.devMode" value="true" />  

国际化设置

Xml代码   收藏代码
  1. <constant name="struts.custom.i18n.resources" value="guest" />  

 

该节点在 Struts.xml 中的配置可以等价于 在 struts.properties 中的 struts.devMode = true 和在 web.xml 中的

Xml代码   收藏代码
  1. <web-app id="WebApp_9" version="2.4"   
  2.     xmlns="http://java.sun.com/xml/ns/j2ee"   
  3.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   
  4.     xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">  
  5.   
  6.     <filter>  
  7.         <filter-name>struts</filter-name>  
  8.         <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>  
  9.         <init-param>  
  10.             <param-name>struts.devMode</param-name>  
  11.             <param-value>true</param-value>  
  12.         </init-param>  
  13.     </filter>  
  14.   
  15.     ...  
  16.   
  17. </web-app>  

 

2、package节点   

 

Struts 中的 package 可以理解为 java 中的包,可以将一组业务相关的 actions 、 results 、 result types 、interceptors 划分在一起与其他业务进行分组。当然它也有子包的概念,如果有子 package ,则父 package 必须在子 package 前配置。

         Name :唯一标识

         Namespace :默认的命名空间为空字符串,要是加上非空字符串如“ test ”,访问时,就改为了“/test/delete.action ” 这里需要多说一点是 Struts 官方文档特别强调一点是 namespace are not a path ,即如果有一个 namespace 为“ /barspace/myspace /bar.action ”, struts 会到“ /barspace/myspace ”下去找bar.action 如果找不到,会直接返回到默认的 namespace(“”) 中去找。

extends="struts-default" 通常每个包都应该继承 struts-default 包,因为 Struts2 很多核心的功能都是拦截器来实现。如:从请求中把请求参数封装到 action 、文件上传和数据验证等等都是通过拦截器实现的。 struts-default 定义了这些拦截器和 Result 类型。因此,当包继承了 struts-default 才能使用 struts2 提供的核心功能。

Xml代码   收藏代码
  1. <package name="default" extends="struts-default" namespace="/">  

 

3、 include 节点:

文档中提到一个策略叫“分而治之”,配置文件也是,可以将部门配置写入到其他的配置文件(格式也需要与struts.xml 中一样)中去,最后引入。

Xml代码   收藏代码
  1. <!DOCTYPE struts PUBLIC  
  2.   "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"  
  3.   "http://struts.apache.org/dtds/struts-2.0.dtd">  
  4. <struts>  
  5.     <include file="Home.xml"/>  
  6.     <include file="Hello.xml"/>  
  7.     <include file="/util/POJO.xml"/>  
  8.     <include file="/com/initech/admin/admin-struts.xml"/>  
  9. </struts>  

 

请求处理元素:

1 、 Interceptor 节点:

拦截器允许您定义的代码执行之前或之后执行的动作方法。 (“ 过滤器 ” 模式 ) 。拦截器是一种强大的工具在开发应用程序。有许多 , 许多用例对拦截器 , 包括验证、属性、安全性、日志记录和分析。

       多个拦截器可以作为一个拦截器堆栈,例如如果要检查客户端证书、时间等信息,所有的这些可以做成部分功能相同的拦截器堆栈。

       拦截器和拦截器堆栈可以混合使用;

Xml代码   收藏代码
  1. <interceptors>  
  2. <!-- 定义拦截器 name:拦截器名称class:拦截器类路径-->  
  3. <interceptor name="timer" class="com.kay.timer"></interceptor>  
  4. <!-- 定义拦截器栈 -->  
  5.     <interceptor-stack name="appDefault">  
  6. <interceptor-ref name="timer"></interceptor-ref>  
  7.         <interceptor-ref name="defaultStack">  
  8.             <param name="exception.logEnabled">true</param>  
  9.             <param name="exception.logLevel">ERROR</param>  
  10.         </interceptor-ref>  
  11.     </interceptor-stack>  
  12. </interceptors>  
  13. <!-- 定义默认的拦截器 每个Action都会自动引用  
  14. 如果Action中引用了其它的拦截器 默认的拦截器将无效 --> <default-interceptor-ref name="appDefault" />   
  15. <action name="hello" class="com.kay.struts2.Action.LoginAction">  
  16. <!-- 引用拦截器name:拦截器名称或拦截器栈名称-->  
  17. <interceptor-ref name="timer"></interceptor-ref>  
  18. <result name="success" type="dispatcher">/talk.jsp</result>  
  19. </action>  

 

2 、 action 节点:

         Action 是 Struts2 的基本工作单元, Action 通过一个标识符与处理程序映射,当一个请求匹配 action 的name 时, Struts2 容器决定调用哪个 Action 来处理用户请求。

         每个 Action 可以指定多个 result 、 ExceptionHandler 、 Intercepter 。但是只能指定一个 name 。在应用程序中, name 属性会去掉 Host , Application 和后缀等信息,得到 Action 的名字。

         在 Struts2 中,一个指向 Action 的链接通常由 Struts 标签产生,这个标签只需要指定 Action 的名字,Struts 框架会自动添加后缀等扩展。

Jsp代码   收藏代码
  1. <s:form action="Hello">  
  2.     <s:textfield label="Please enter your name" name="name"/>  
  3.     <s:submit/>  
  4. </s:form>  
 

在定义 Action 的 name 时,最好使用英文字面和下划线,而不要使用“ . ”和“ / ” ;

Xml代码   收藏代码
  1. <action name="index" class="com.iflytek.action.ListEmployeeAction">  
  2. <result name="success">/page/employeeList.jsp</result>  
  3. </action>  

 

Action 标签中如果没用置顶 method ,则默认是 execute ,否则就可以指定到 Action 类中的不同方法。Method 上的通配符使用,很多时候 , 一组 Action 映射将共享一个共同的模式( delete 、 add 、 update )。例如 , 你所有的编辑动作可以用单词 “ 编辑 ”, 并调用编辑方法操作类,这时就可以使用通配符。

Xml代码   收藏代码
  1. <action name="*User" class="com.iflytek.model" method="{1}">  

 

当我们没有指定 Action 的 class 属性的时候,我们默认使用 com.opensymphony.xwork.ActionSupport ,ActionSupport 有两个方法 input 和 execute ,每个方法都是简单的返回 SUCCESS 。

  使用如下代码可以实现刷新的效果

Jsp代码   收藏代码
  1. <s:form>   
  2.      <s:textfield label="Please enter your name" name="name"/>   
  3.     <s:submit/>   
  4. </s:form>  
 

 

通常情况下,请求的 Action 不存在的情况下, Struts2 框架会返回一个 Error 页面:“ 404 - Page not found ”,如果我们不想出现一个控制之外的错误页面,我们可以指定一个默认的 Action ,在请求的 Action 不存在的情况下,调用默认的 Action ,通过如下配置可以达到要求:

Xml代码   收藏代码
  1. <package name="Hello" extends="action-default">  
  2.     <default-action-ref name="UnderConstruction"/>  
  3.     <action name="UnderConstruction">  
  4.         <result>/UnderConstruction.jsp</result>  
  5.     </action>  
  6.     ...  

 

默认通配符 

Xml代码   收藏代码
  1. <action name="*" >   
  2. <result>/{1}.jsp</result>   
  3. </action>   

 每个 Action 将会被映射到以自己名字明明的 JSP 上。

 

 

通配符:

Xml代码   收藏代码
  1. <action name="/edit*" class="org.apache.struts.webapp.example.Edit{1}Action">  
  2.     <result name="failure">/mainMenu.jsp</result>  
  3.     <result>edit_{1}.jsp</result>  
  4. </action>  

 

上面匹配的结果将替换{ 1 }

* :将匹配零个或多个字符不包括斜杠 (/) 字符。

** :将匹配零个或多个字符包括斜杠 (/) 字符。

当然还支持正则等,这个这里就不描述了

注意如果使用正则需要在配置:

Xml代码   收藏代码
  1. <constant name="struts.enable.SlashesInActionNames" value="true"/>  
  2. <constant name="struts.mapper.alwaysSelectFullNamespace" value="false"/>  
  3. <constant name="struts.patternMatcher" value="regex" />  

 

3、 result 节点:

定义Action的结果视图,name表示结果视图名称,默认为success,type为结果视图类型,默认为dispathcher

String SUCCESS = "success";
String NONE    = "none";
String ERROR   = "error";
String INPUT   = "input";
String LOGIN   = "login";

 

A 、设置默认返回类型:

Xml代码   收藏代码
  1. <result-types>  
  2.    <result-type name="dispatcher" default="true"  
  3.              class="org.apache.struts2.dispatcher.ServletDispatcherResult" />  
  4. </result-types>  

 

B 、多个返回类型:

Xml代码   收藏代码
  1. <action name="Hello">  
  2.     <result>/hello/Result.jsp</result>  
  3.     <result name="error">/hello/Error.jsp</result>  
  4.     <result name="input">/hello/Input.jsp</result>  
  5.     <result name="*">/hello/Other.jsp</result>  
  6. </action>  

 在 name = " * " 不是一个通配符模式 , 它是一个特殊的名称 , 是唯一选择的如果没有找到一个精确的匹配。

 

C 、全局返回类型:

         通常 , 结果是嵌套在 Action 中。但是一些结果适用于多种 Action 。在一个安全的应用程序 , 客户端可能会试图访问一个页面没有被授权 , 许多 Action 可能需要访问一个“登录”的页面。

Xml代码   收藏代码
  1. <global-results>  
  2.     <result name="error">/Error.jsp</result>  
  3.     <result name="invalid.token">/Error.jsp</result>  
  4.     <result name="login" type="redirectAction">Logon!input</result>  
  5. </global-results>  
 

 

D 、动态返回类型:

Xml代码   收藏代码
  1. <struts>  
  2. ....  
  3.    <package name="somePackage" namespace="/myNamespace" extends="struts-default">  
  4.       <action name="myAction" class="com.project.MyAction">  
  5.          <result name="success" type="redirectAction">otherAction?id=${id}</result>  
  6.          <result name="back" type="redirect">${redirectURL}</result>  
  7.       </action>  
  8.   
  9.       <action name="otherAction" class="com.project.MyOtherAction">  
  10.          ...  
  11.       </action>        
  12.    </package>  
  13. ....  
  14. </struts>  
 
Java代码   收藏代码
  1. public class MyAction extends ActionSupport {  
  2.    private int id;  
  3.    private String redirectURL;  
  4.    ...  
  5.   
  6.   
  7.    public String execute() {  
  8.        ...  
  9.       if (someCondition) {  
  10.          this.redirectURL = "/the/target/page.action";  
  11.          return "back";  
  12.       }  
  13.   
  14.       this.id = 123;  
  15.       return SUCCESS;   
  16.    }  
  17.   
  18.    public int getId() { return this.id; }  
  19.    public void setId(int id) { this.id = id; }  
  20.    public String getRedirectURL() { return this.redirectURL; }  
  21.    public void setRedirectURL(String redirectURL) { this.redirectURL= redirectURL; }  
  22.    ...  
  23. }  

 

result 的 type :

                   1 、 Chain          : 用来处理 Action 链

                   2 、 Dispatcher      : 用来转向页面,通常处理 JSP( 默认值 )

                   3 、 FreeMarker    : 处理 FreeMarker 模板

                   4 、 HttpHeader      : 用来控制特殊的 Http 行为

                   5 、 Redirect        : 重定向到一个 URL

                   6 、 Redirect-Action : 重定向到一个 Action

                   7 、 Stream          : 向浏览器发送 InputSream 对象,通常用来处理文件下载

                   8 、 Velocity        :处理 Velocity 模板

                   9 、 XLS             :处理 XML/XLST 模板

                   10 、 PlainText       :显示原始文件内容,例如文件源代码

                   11 、 S2PLUGINS:Tiles : 结合 Tile 使用

 

 

4 、 Unknown Handlers 节点:

Xml代码   收藏代码
  1. <bean type="com.opensymphony.xwork2.UnknownHandler" name="handler1" class="com.opensymphony.xwork2.config.providers.SomeUnknownHandler"/>  
  2. <bean type="com.opensymphony.xwork2.UnknownHandler" name="handler2" class="com.opensymphony.xwork2.config.providers.SomeUnknownHandler"/>  
  3.   
  4. <unknown-handler-stack>  
  5.    <unknown-handler-ref name="handler1" />  
  6.    <unknown-handler-ref name="handler2" />  
  7. </unknown-handler-stack>  

 

 

 

错误处理元素:

Exception 节点:

 

         Struts 的异常映射是一个比较强大的特性,其核心就是在异常期间抛出的动作方法可以自动捕获并映射到一个预定的结果中。

         默认的异常映射是在默认的拦截器中进行激活的,可以看看下面的 strusts-default.xml

Xml代码   收藏代码
  1. ...  
  2. <interceptors>  
  3.     ...  
  4.     <interceptor name="exception" class="com.opensymphony.xwork.interceptor.ExceptionMappingInterceptor"/>  
  5.     ...  
  6. </interceptors>  
  7.   
  8. <interceptor-stack name="defaultStack">  
  9.     <interceptor-ref name="exception"/>  
  10.     <interceptor-ref name="alias"/>  
  11.     <interceptor-ref name="servlet-config"/>  
  12.     <interceptor-ref name="prepare"/>  
  13.     <interceptor-ref name="i18n"/>  
  14.     <interceptor-ref name="chain"/>  
  15.     <interceptor-ref name="debugging"/>  
  16.     <interceptor-ref name="profiling"/>  
  17.     <interceptor-ref name="scoped-model-driven"/>  
  18.     <interceptor-ref name="model-driven"/>  
  19.     <interceptor-ref name="fileUpload"/>  
  20.     <interceptor-ref name="checkbox"/>  
  21.     <interceptor-ref name="static-params"/>  
  22.     <interceptor-ref name="params"/>  
  23.     <interceptor-ref name="conversionError"/>  
  24.     <interceptor-ref name="validation">  
  25.         <param name="excludeMethods">input,back,cancel,browse</param>  
  26.     </interceptor-ref>  
  27.     <interceptor-ref name="workflow">  
  28.         <param name="excludeMethods">input,back,cancel,browse</param>  
  29.     </interceptor-ref>  
  30. </interceptor-stack>  
  31. ...  
  32.    
 
Xml代码   收藏代码
  1. <struts>  
  2.     <package name="default">  
  3.         ...  
  4.         <global-results>  
  5.             <result name="login" type="redirect">/Login.action</result>  
  6.             <result name="Exception">/Exception.jsp</result>  
  7.         </global-results>  
  8.   
  9.         <global-exception-mappings>  
  10.             <exception-mapping exception="java.sql.SQLException" result="SQLException"/>  
  11.             <exception-mapping exception="java.lang.Exception" result="Exception"/>  
  12.         </global-exception-mappings>  
  13.         ...  
  14.         <action name="DataAccess" class="com.company.DataAccess">  
  15.             <exception-mapping exception="com.company.SecurityException" result="login"/>  
  16.             <result name="SQLException" type="chain">SQLExceptionAction</result>  
  17.             <result>/DataAccess.jsp</result>  
  18.         </action>  
  19.         ...  
  20.     </package>  
  21. </struts>  
 

 

ValueStack 中的 value

 

 

Jsp代码   收藏代码
  1. <h2>An unexpected error has occurred</h2>  
  2. <p>  
  3.     Please report this error to your system administrator  
  4.     or appropriate technical support personnel.  
  5.     Thank you for your cooperation.  
  6. </p>  
  7. <hr/>  
  8. <h3>Error Message</h3>  
  9. <s:actionerror/>  
  10. <p>  
  11.     <s:property value="%{exception.message}"/>  
  12. </p>  
  13. <hr/>  
  14. <h3>Technical Details</h3>  
  15. <p>  
  16.     <s:property value="%{exceptionStack}"/>  
  17. </p>  

 

 

三、 struts.properties :

在该文件中,可以设置一些参数,使得 struts 适合你的要求,例如编码等,下面列出一个默认的配置:

 

Properties代码   收藏代码
  1. ### Struts default properties  
  2. ###(can be overridden by a struts.properties file in the root of the classpath)  
  3. ###  
  4.   
  5. ### Specifies the Configuration used to configure Struts  
  6. ### one could extend org.apache.struts2.config.Configuration  
  7. ### to build one's customize way of getting the configurations parameters into Struts  
  8. # struts.configuration=org.apache.struts2.config.DefaultConfiguration  
  9.   
  10. ### This can be used to set your default locale and encoding scheme  
  11. # struts.locale=en_US  
  12. struts.i18n.encoding=UTF-8  
  13.   
  14. ### if specified, the default object factory can be overridden here  
  15. ### Note: short-hand notation is supported in some cases, such as "spring"  
  16. ###       Alternatively, you can provide a com.opensymphony.xwork2.ObjectFactory subclass name here  
  17. # struts.objectFactory = spring  
  18.   
  19. ### specifies the autoWiring logic when using the SpringObjectFactory.  
  20. ### valid values are: name, type, auto, and constructor (name is the default)  
  21. struts.objectFactory.spring.autoWire = name  
  22.   
  23. ### indicates to the struts-spring integration if Class instances should be cached  
  24. ### this should, until a future Spring release makes it possible, be left as true  
  25. ### unless you know exactly what you are doing!  
  26. ### valid values are: true, false (true is the default)  
  27. struts.objectFactory.spring.useClassCache = true  
  28.   
  29. ### ensures the autowire strategy is always respected.  
  30. ### valid values are: true, false (false is the default)  
  31. struts.objectFactory.spring.autoWire.alwaysRespect = false  
  32.   
  33. ### if specified, the default object type determiner can be overridden here  
  34. ### Note: short-hand notation is supported in some cases, such as "tiger" or "notiger"  
  35. ###       Alternatively, you can provide a com.opensymphony.xwork2.util.ObjectTypeDeterminer implementation name here  
  36. ### Note: By default, com.opensymphony.xwork2.util.DefaultObjectTypeDeterminer is used which handles type detection  
  37. ###       using generics. com.opensymphony.xwork2.util.GenericsObjectTypeDeterminer was deprecated since XWork 2, it's  
  38. ###       functions are integrated in DefaultObjectTypeDeterminer now.  
  39. ###       To disable tiger support use the "notiger" property value here.  
  40. #struts.objectTypeDeterminer = tiger  
  41. #struts.objectTypeDeterminer = notiger  
  42.   
  43. ### Parser to handle HTTP POST requests, encoded using the MIME-type multipart/form-data  
  44. # struts.multipart.parser=cos  
  45. # struts.multipart.parser=pell  
  46. struts.multipart.parser=jakarta  
  47. # uses javax.servlet.context.tempdir by default  
  48. struts.multipart.saveDir=  
  49. struts.multipart.maxSize=2097152  
  50.   
  51. ### Load custom property files (does not override struts.properties!)  
  52. # struts.custom.properties=application,org/apache/struts2/extension/custom  
  53.   
  54. ### How request URLs are mapped to and from actions  
  55. #struts.mapper.class=org.apache.struts2.dispatcher.mapper.DefaultActionMapper  
  56.   
  57. ### Used by the DefaultActionMapper  
  58. ### You may provide a comma separated list, e.g. struts.action.extension=action,jnlp,do  
  59. ### The blank extension allows you to match directory listings as well as pure action names  
  60. ### without interfering with static resources.  
  61. struts.action.extension=action,,  
  62.   
  63. ### Used by FilterDispatcher  
  64. ### If true then Struts serves static content from inside its jar.  
  65. ### If false then the static content must be available at <context_path>/struts  
  66. struts.serve.static=true  
  67.   
  68. ### Used by FilterDispatcher  
  69. ### This is good for development where one wants changes to the static content be  
  70. ### fetch on each request.  
  71. ### NOTE: This will only have effect if struts.serve.static=true  
  72. ### If true -> Struts will write out header for static contents such that they will  
  73. ###             be cached by web browsers (using Date, Cache-Content, Pragma, Expires)  
  74. ###             headers).  
  75. ### If false -> Struts will write out header for static contents such that they are  
  76. ###            NOT to be cached by web browser (using Cache-Content, Pragma, Expires  
  77. ###            headers)  
  78. struts.serve.static.browserCache=true  
  79.   
  80. ### Set this to false if you wish to disable implicit dynamic method invocation  
  81. ### via the URL request. This includes URLs like foo!bar.action, as well as params  
  82. ### like method:bar (but not action:foo).  
  83. ### An alternative to implicit dynamic method invocation is to use wildcard  
  84. ### mappings, such as <action name="*/*" method="{2}" class="actions.{1}">  
  85. struts.enable.DynamicMethodInvocation = true  
  86.   
  87. ### Set this to true if you wish to allow slashes in your action names.  If false,  
  88. ### Actions names cannot have slashes, and will be accessible via any directory  
  89. ### prefix.  This is the traditional behavior expected of WebWork applications.  
  90. ### Setting to true is useful when you want to use wildcards and store values  
  91. ### in the URL, to be extracted by wildcard patterns, such as  
  92. ### <action name="*/*" method="{2}" class="actions.{1}"> to match "/foo/edit" or  
  93. ### "/foo/save".  
  94. struts.enable.SlashesInActionNames = false  
  95.   
  96. ### use alternative syntax that requires %{} in most places  
  97. ### to evaluate expressions for String attributes for tags  
  98. struts.tag.altSyntax=true  
  99.   
  100. ### when set to true, Struts will act much more friendly for developers. This  
  101. ### includes:  
  102. ### - struts.i18n.reload = true  
  103. ### - struts.configuration.xml.reload = true  
  104. ### - raising various debug or ignorable problems to errors  
  105. ###   For example: normally a request to foo.action?someUnknownField=true should  
  106. ###                be ignored (given that any value can come from the web and it  
  107. ###                should not be trusted). However, during development, it may be  
  108. ###                useful to know when these errors are happening and be told of  
  109. ###                them right away.  
  110. struts.devMode = false  
  111.   
  112. ### when set to true, resource bundles will be reloaded on _every_ request.  
  113. ### this is good during development, but should never be used in production  
  114. struts.i18n.reload=false  
  115.   
  116. ### Standard UI theme  
  117. ### Change this to reflect which path should be used for JSP control tag templates by default  
  118. struts.ui.theme=xhtml  
  119. struts.ui.templateDir=template  
  120. #sets the default template type. Either ftl, vm, or jsp  
  121. struts.ui.templateSuffix=ftl  
  122.   
  123. ### Configuration reloading  
  124. ### This will cause the configuration to reload struts.xml when it is changed  
  125. struts.configuration.xml.reload=false  
  126.   
  127. ### Location of velocity.properties file.  defaults to velocity.properties  
  128. struts.velocity.configfile = velocity.properties  
  129.   
  130. ### Comma separated list of VelocityContext classnames to chain to the StrutsVelocityContext  
  131. struts.velocity.contexts =  
  132.   
  133. ### Location of the velocity toolbox  
  134. struts.velocity.toolboxlocation=  
  135.   
  136. ### used to build URLs, such as the UrlTag  
  137. struts.url.http.port = 80  
  138. struts.url.https.port = 443  
  139. ### possible values are: none, get or all  
  140. struts.url.includeParams = none  
  141.   
  142. ### Load custom default resource bundles  
  143. # struts.custom.i18n.resources=testmessages,testmessages2  
  144.   
  145. ### workaround for some app servers that don't handle HttpServletRequest.getParameterMap()  
  146. ### often used for WebLogic, Orion, and OC4J  
  147. struts.dispatcher.parametersWorkaround = false  
  148.   
  149. ### configure the Freemarker Manager class to be used  
  150. ### Allows user to plug-in customised Freemarker Manager if necessary  
  151. ### MUST extends off org.apache.struts2.views.freemarker.FreemarkerManager  
  152. #struts.freemarker.manager.classname=org.apache.struts2.views.freemarker.FreemarkerManager  
  153.   
  154. ### Enables caching of FreeMarker templates  
  155. ### Has the same effect as copying the templates under WEB_APP/templates  
  156. struts.freemarker.templatesCache=false  
  157.   
  158. ### Enables caching of models on the BeanWrapper  
  159. struts.freemarker.beanwrapperCache=false  
  160.   
  161. ### See the StrutsBeanWrapper javadocs for more information  
  162. struts.freemarker.wrapper.altMap=true  
  163.   
  164. ### maxStrongSize for MruCacheStorage for freemarker  
  165. struts.freemarker.mru.max.strong.size=100  
  166.   
  167. ### configure the XSLTResult class to use stylesheet caching.  
  168. ### Set to true for developers and false for production.  
  169. struts.xslt.nocache=false  
  170.   
  171. ### Whether to always select the namespace to be everything before the last slash or not  
  172. struts.mapper.alwaysSelectFullNamespace=false  
  173.   
  174. ### Whether to allow static method access in OGNL expressions or not  
  175. struts.ognl.allowStaticMethodAccess=false  
  176.   
  177. ### Whether to throw a RuntimeException when a property is not found  
  178. ### in an expression, or when the expression evaluation fails  
  179. struts.el.throwExceptionOnFailure=false  
  180.   
  181. ### Logs as Warnings properties that are not found (very verbose)  
  182. struts.ognl.logMissingProperties=false  
  183.   
  184. ### Caches parsed OGNL expressions, but can lead to memory leaks  
  185. ### if the application generates a lot of different expressions  
  186. struts.ognl.enableExpressionCache=true  

 

其他文件一般在项目中都很少去涉及,除非特定的需求,所以就不在往下说了,具体可以查阅官方的文档。 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值