struts2的struts.properties程序解析

/*
* $Id: StrutsConstants.java 422956 2006-07-18 04:15:02Z mrdon $
*
* Copyright 2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*      http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.struts2;

/**
* This class provides a central location for framework configuration keys used
* to retrieve and store Struts configuration settings.
*/
public final class StrutsConstants {

  /** Whether Struts is in development mode or not */
  public static final String STRUTS_DEVMODE = "struts.devMode";// 是否爲開發模式

  /** Whether the localization messages should automatically be reloaded */
  public static final String STRUTS_I18N_RELOAD = "struts.i18n.reload";// 國際化信息是否可以被重新裝載
  //  當設置爲true,資源包會在每個請求時自動重新載入.  這在開發時很方便,但是不應該在生產狀態下使用
  /** The encoding to use for localization messages */
  public static final String STRUTS_I18N_ENCODING = "struts.i18n.encoding";// 國際化信息的編碼,struts2’s character encoding set.
  //用來設置你的缺省 locale和編碼方案
  /** Whether to reload the XML configuration or not */
  public static final String STRUTS_CONFIGURATION_XML_RELOAD = "struts.configuration.xml.reload";// 是否重新裝載xml中的配置信息,開發過程中設置爲可以

  /**
   * The URL extension to use to determine if the request is meant for a
   * Struts action
   */
  public static final String STRUTS_ACTION_EXTENSION = "struts.action.extension";// 是否使用web.xml中定義的後綴作爲映射條件。 Mapping extension used in web.xml.
  //  DefaultActionMapper使用的設置
  //  你可以提供一個逗號分割的列表,例如 webwork.action.extension=action,jnlp,do
  
  /** Whether to use the alterative syntax for the tags or not */
  public static final String STRUTS_TAG_ALTSYNTAX = "struts.tag.altSyntax";
  //使用 alternative syntax 在大多數地方需要 %{} 來計算標籤的字符串屬性的值
  /**
   * 從webwork.tag.altSyntax的字面上看,這個屬性與tag相關,而且altSyntax中的alt就是alternative的意思,那麼與Syntax合在一起,就應該表示另外一種可供選擇的語法了。在查閱了相關文檔,包括《WebWork
   * In
   * Action》的第三章之後,對這個屬性有了比較全面的認識。在WebWork2.1.7中,altSyntax的default值爲false,在這種情況下並不支持新的語法。那麼在舊的語法中,如果要爲標籤的某一屬性設置String類型的值,就必須給這個值加上單引號了,這是由WebWork所支持的OGNL語法決定的。如果你不使用單引號將用以賦值的value括起來的話,那麼這個value將會被認爲是存在於Value
   * Stack的Object所對應的key,在標籤被parse的過程中,就會以這個value爲key到Value
   * Stack中找對應的內容,結果是可想而知的了——找不到,因爲你根本就沒有往Value Stack中增加這樣的鍵值對。以昨天的Post中的代碼爲例:
   * <ww:textfield label="Please enter your name:" name="name" />
   * 在舊的語法體系裏,textfield標籤被parse的過程中,label的值"Please enter your
   * name:"會被當作是一個Key,從Value
   * Stack中找相應的內容,並返回找到的內容作爲label屬性的值。這很明顯是拿不到具體的值的,最後將會返回一個空字符串。這正好與昨天出現的錯誤情況是吻合的。爲了直接給label設置String值,我們就要使用單引號將具體的String值括起來了。這樣的語法確實很靈活,你可以讓JSP擁有更多的動態性,但是不好的地方也很明顯,頁面將會充斥着單引號和雙引號的混合體,代碼將難以維護。於是,新的語法被提了出來:使用%{...}來指明某一個部分需要到Value
   * Stack中取值,這樣就可以將多餘的單引號去掉了。爲了使用新的語法,我們就必須將altSyntax設爲true。這一點在WebWork2.1.7的使用過程中,尤爲需要注意的。
   * 最後再強調一點,在WebWork2.2中,將會全面啓用新的語法,也就是altSyntax的默認值爲true了,甚至壓根就會把這個屬性值給去掉。所以,大家還是應該以新的語法爲準,而且新的語法會更好用,你說呢?
   *
   */
  /** The HTTP port used by Struts URLs */
  public static final String STRUTS_URL_HTTP_PORT = "struts.url.http.port";//http的端口號,默認爲80

  /** The HTTPS port used by Struts URLs */
  public static final String STRUTS_URL_HTTPS_PORT = "struts.url.https.port";//https的端口號默認爲443

  /** The com.opensymphony.xwork.ObjectFactory implementation class */
  public static final String STRUTS_OBJECTFACTORY = "struts.objectFactory";//配置objectFactory
  //如果指定了,缺省的ojbect factory在這裏可以被覆蓋
  //  注意:縮寫在某些情況下是支持的,例如 "spring" .作爲代替,你可以提供一個 com.opensymphony.xwork2.ObjectFactory 子類的名稱
  //key=spring  value=org.apache.struts2.spring.StrutsSpringObjectFactory
  //key=plexus  vlaue=org.apache.struts2.plexus.PlexusObjectFactory

  /** The com.opensymphony.xwork.util.ObjectTypeDeterminer implementation class */
  public static final String STRUTS_OBJECTTYPEDETERMINER = "struts.objectTypeDeterminer";//對象類型的限定詞
  //  如果設定了,缺省的對象類型裁決者可以被覆蓋
  // note: this class name needs to be in string form so we don't put hard
   //       dependencies on xwork-tiger, since it isn't technically required.
  //  注意: 縮寫在某些情況下支持,例如 "tiger" or "notiger"
  //  tiger = com.opensymphony.xwork2.util.GenericsObjectTypeDeterminer
  //  notiger = com.opensymphony.xwork2.util.DefaultObjectTypeDeterminer
  //  關閉tiger支持,在這裏使用 "notiger" 屬性值.

  /** The package containing actions that use Rife continuations */
  public static final String STRUTS_CONTINUATIONS_PACKAGE = "struts.continuations.package";//

  /** The org.apache.struts2.config.Configuration implementation class */
  public static final String STRUTS_CONFIGURATION = "struts.configuration";//org.apache.struts2.config.Configuration的實現類

  /** The default locale for the Struts application */
  public static final String STRUTS_LOCALE = "struts.locale";//默認的struts2應用方言,應用於i18n

  /**
   * Whether to use a Servlet request parameter workaround necessary for some
   * versions of WebLogic
   */
  public static final String STRUTS_DISPATCHER_PARAMETERSWORKAROUND = "struts.dispatcher.parametersWorkaround";
  //有些app server不能處理HttpServletRequest.getParameterMap(),經常使用的是WebLogic,Orion和OC4J
  
  /**
   * The org.apache.struts2.views.freemarker.FreemarkerManager implementation
   * class
   */
  public static final String STRUTS_FREEMARKER_MANAGER_CLASSNAME = "struts.freemarker.manager.classname";

  /** org.apache.struts2.views.velocity.VelocityManager implementation class */
  public static final String STRUTS_VELOCITY_MANAGER_CLASSNAME = "struts.velocity.manager.classname";

  /** The Velocity configuration file path */
  public static final String STRUTS_VELOCITY_CONFIGFILE = "struts.velocity.configfile";//velocity配置文件所在。Where to look for Velocity-related configuration.
  //缺省是 velocity.properties
  /** The location of the Velocity toolbox */
  public static final String STRUTS_VELOCITY_TOOLBOXLOCATION = "struts.velocity.toolboxlocation";//velocity toolbox location

  /** List of Velocity context names */
  public static final String STRUTS_VELOCITY_CONTEXTS = "struts.velocity.contexts";//

  /** The directory containing UI templates */
  public static final String STRUTS_UI_TEMPLATEDIR = "struts.ui.templateDir";//默認包含UI模版的文件夾

  /** The default UI template theme */
  public static final String STRUTS_UI_THEME = "struts.ui.theme";//默認的UI主題模版。webwork中的解釋“xhtml” Default UI tag theme to use.
  //  標準的UI theme,  改變這個會映射缺省由那個路徑的模板來輸出JSP控件標籤
  /** The maximize size of a multipart request (file upload) */
  public static final String STRUTS_MULTIPART_MAXSIZE = "struts.multipart.maxSize";//設置上傳附件大小的最大值,單位byte

  /** The directory to use for storing uploaded files */
  public static final String STRUTS_MULTIPART_SAVEDIR = "struts.multipart.saveDir";//設置上傳文件保存的文件夾

  /**
   * The org.apache.struts2.dispatcher.multipart.MultiPartRequest parser
   * implementation for a multipart request (file upload)
   */
  public static final String STRUTS_MULTIPART_PARSER = "struts.multipart.parser";//設置上傳解析類,用來處理HTTP POST請求,編碼使用MIME-type multipart/form-data方式的

  /** Whether Spring should autoWire or not */
  public static final String STRUTS_OBJECTFACTORY_SPRING_AUTOWIRE = "struts.objectFactory.spring.autoWire";
  //指定當使用SpringObjectFactory時的自動裝配邏輯.
  //合法值包括: name, type, auto, 和 constructor (缺省爲 name )

  /** Whether Spring should use its class cache or not */
  public static final String STRUTS_OBJECTFACTORY_SPRING_USE_CLASS_CACHE = "struts.objectFactory.spring.useClassCache";//是否允許spring使用它的class緩存。
  //  標識struts-spring集成,如果類實例應該被緩存.這可能,直到將來Spring版本讓它變得可能,否則就保持它爲true
  //  除非你確切的知道你在做什麼,否則不要改變
  //  合法的值包括: true, false (true 是缺省的)
  /** Whether or not XSLT templates should not be cached */
  public static final String STRUTS_XSLT_NOCACHE = "struts.xslt.nocache";//是否支持xslt緩存
  //配置 XSLTResult 類使用 stylesheet 緩存.  開發時設置爲true,生產時設置爲false.
  
  /** Location of additional configuration properties files to load */
  public static final String STRUTS_CUSTOM_PROPERTIES = "struts.custom.properties";//支持額外的properties配置文件
  //裝載定製的屬性文件(不會覆蓋struts.properties!)

  /** Location of additional localization properties files to load */
  public static final String STRUTS_CUSTOM_I18N_RESOURCES = "struts.custom.i18n.resources";//客戶定製的i18n資源信息
//可以增加多個properties文件的名稱,使用逗號或者空格分割。
  /**
   * The org.apache.struts2.dispatcher.mapper.ActionMapper implementation
   * class
   */
  public static final String STRUTS_MAPPER_CLASS = "struts.mapper.class";//配置映射類
  //  用來處理request URL如何映射到action,或者相反的映射(用戶可以實現自己的處理)
  //  struts.mapper.class=com.opensymphony.webwork.dispatcher.mapper.DefaultActionMapper
  
  /** Whether the Struts filter should serve static content or not */
  public static final String STRUTS_SERVE_STATIC_CONTENT = "struts.serve.static";//struts過濾器是否支持靜態內容
  //  FilterDispatcher使用的設置
  //  如果爲true,那麼struts將會爲它jar包內的靜態文件提供服務.
  //  如果爲false,那麼靜態文件必須在<context_path>/struts下面可以訪問
  /**
   * If static content served by the Struts filter should set browser caching
   * header properties or not
   */
  public static final String STRUTS_SERVE_STATIC_BROWSER_CACHE = "struts.serve.static.browserCache";//是否緩存header屬性值
  //true 使用緩存,false不使用瀏覽器緩存。
  
  /** Whether Struts is in WebWork 2.2 compatibility mode or not */
  public static final String STRUTS_COMPATIBILITY_MODE = "struts.compatibilityMode";//是否兼容webwork2.2
}



附件default.properties文件


### START SNIPPET: complete_file

### Struts default properties
###(can be overridden by a struts.properties file in the root of the classpath)
###

### Specifies the Configuration used to configure Struts
### one could extend org.apache.struts2.config.Configuration
### to build one's customize way of getting the configurations parameters into Struts
# struts.configuration=org.apache.struts2.config.DefaultConfiguration

### This can be used to set your default locale and encoding scheme
# struts.locale=en_US
struts.i18n.encoding=UTF-8

### if specified, the default object factory can be overridden here
### Note: short-hand notation is supported in some cases, such as "spring"
###       Alternatively, you can provide a com.opensymphony.xwork2.ObjectFactory subclass name here  
# struts.objectFactory = spring

### specifies the autoWiring logic when using the SpringObjectFactory.
### valid values are: name, type, auto, and constructor (name is the default)
struts.objectFactory.spring.autoWire = name

### indicates to the struts-spring integration if Class instances should be cached
### this should, until a future Spring release makes it possible, be left as true
### unless you know exactly what you are doing!
### valid values are: true, false (true is the default)
struts.objectFactory.spring.useClassCache = true

### if specified, the default object type determiner can be overridden here
### Note: short-hand notation is supported in some cases, such as "tiger" or "notiger"
###       Alternatively, you can provide a com.opensymphony.xwork2.util.ObjectTypeDeterminer implementation name here
### Note: if you have the xwork-tiger.jar within your classpath, GenericsObjectTypeDeterminer is used by default
###       To disable tiger support use the "notiger" property value here.
#struts.objectTypeDeterminer = tiger
#struts.objectTypeDeterminer = notiger

### Parser to handle HTTP POST requests, encoded using the MIME-type multipart/form-data
# struts.multipart.parser=cos
# struts.multipart.parser=pell
struts.multipart.parser=jakarta
# uses javax.servlet.context.tempdir by default
struts.multipart.saveDir=
struts.multipart.maxSize=2097152

### Load custom property files (does not override struts.properties!)
# struts.custom.properties=application,org/apache/struts2/extension/custom

### How request URLs are mapped to and from actions
struts.mapper.class=org.apache.struts2.dispatcher.mapper.DefaultActionMapper

### Used by the DefaultActionMapper
### You may provide a comma separated list, e.g. struts.action.extension=action,jnlp,do
struts.action.extension=action

### Used by FilterDispatcher
### If true then Struts serves static content from inside its jar.
### If false then the static content must be available at <context_path>/struts
struts.serve.static=true

### Used by FilterDispatcher
### This is good for development where one wants changes to the static content be
### fetch on each request.
### NOTE: This will only have effect if struts.serve.static=true
### If true -> Struts will write out header for static contents such that they will
###             be cached by web browsers (using Date, Cache-Content, Pragma, Expires)
###             headers).
### If false -> Struts will write out header for static contents such that they are
###            NOT to be cached by web browser (using Cache-Content, Pragma, Expires
###            headers)
struts.serve.static.browserCache=true

### use alternative syntax that requires %{} in most places
### to evaluate expressions for String attributes for tags
struts.tag.altSyntax=true

### when set to true, Struts will act much more friendly for developers. This
### includes:
### - struts.i18n.reload = true
### - struts.configuration.xml.reload = true
### - raising various debug or ignorable problems to errors
###   For example: normally a request to foo.action?someUnknownField=true should
###                be ignored (given that any value can come from the web and it
###                should not be trusted). However, during development, it may be
###                useful to know when these errors are happening and be told of
###                them right away.
struts.devMode = false

### when set to true, Struts will support some deprecated WebWork 2.2 idioms.
### Specifically, it allows for the "action!method" URL syntax
### that allows methods to be specified in the URL.  This behavior has been
### deprecated in favor of explicit wildcards where needed.
struts.compatibilityMode = false

### when set to true, resource bundles will be reloaded on _every_ request.
### this is good during development, but should never be used in production
struts.i18n.reload=false

### Standard UI theme
### Change this to reflect which path should be used for JSP control tag templates by default
struts.ui.theme=xhtml
struts.ui.templateDir=template
#sets the default template type. Either ftl, vm, or jsp
struts.ui.templateSuffix=ftl

### Configuration reloading
### This will cause the configuration to reload struts.xml when it is changed
struts.configuration.xml.reload=false

### Location of velocity.properties file.  defaults to velocity.properties
# struts.velocity.configfile = velocity.properties

### Comma separated list of VelocityContext classnames to chain to the StrutsVelocityContext
# struts.velocity.contexts =

### used to build URLs, such as the UrlTag
struts.url.http.port = 80
struts.url.https.port = 443

### Load custom default resource bundles
# struts.custom.i18n.resources=testmessages,testmessages2

### workaround for some app servers that don't handle HttpServletRequest.getParameterMap()
### often used for WebLogic, Orion, and OC4J
struts.dispatcher.parametersWorkaround = false

### configure the Freemarker Manager class to be used
### Allows user to plug-in customised Freemarker Manager if necessary
### MUST extends off org.apache.struts2.views.freemarker.FreemarkerManager
#struts.freemarker.manager.classname=org.apache.struts2.views.freemarker.FreemarkerManager

### See the StrutsBeanWrapper javadocs for more information
struts.freemarker.wrapper.altMap=true

### configure the XSLTResult class to use stylesheet caching.
### Set to true for developers and false for production.
struts.xslt.nocache=false

### END SNIPPET: complete_file
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章