Struts2 configuration: Constant Config[筆記]
Constants provide a simple way to customize a Struts application by defining key settings that modify framework and plugin behavior. There are two key roles for constants. First, they are used to override settings like the maximum file upload size or whether the Struts framework should be in "devMode" or not. Second, they specify which Bean, among multiple implementations of a given type, should be chosen.
常量提供了簡單的途徑來定制一個(gè)Struts應(yīng)用,它是定義關(guān)鍵設(shè)置來改變框架和插件的行為的。常量有兩個(gè)關(guān)鍵作用,第一覆蓋默認(rèn)設(shè)置,例如限定上傳文件的大小或者Struts框架是否因該是devMode。第二,定義在給定類型的多種實(shí)現(xiàn)方面,它們描述那種bean應(yīng)該被選擇。
Constants can be declared in multiple files. By default, constants are searched for in the following order, allowing for subsequent files to override previous ones:
- struts-default.xml
- struts-plugin.xml
- struts.xml
- struts.properties
- web.xml
The struts.properties file is provided for backward-compatiblity with WebWork.
In the various XML variants, the constant element has two required attributes: name and value.
Attribute | Required | Description |
---|---|---|
name | yes | the name of the constant |
value | *yes | the value of the constant |
In the struts.properties file, each entry is treated as a constant.
In the web.xml file, any FilterDispatcher initialization parameters are loaded as constants.
Sample usage
<struts>
<constant name="struts.devMode" value="true" />
...
</struts>
struts.devMode = true
<web-app id="WebApp_9" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<filter>
<filter-name>struts</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
<init-param>
<param-name>struts.devMode</param-name>
<param-value>true</param-value>
</init-param>
</filter>
...
</web-app>
posted on 2007-04-26 21:30 MingIsMe 閱讀(981) 評論(0) 編輯 收藏 所屬分類: Struts2學(xué)習(xí)