查看文章 |
struts2的struts.properties程序解析
2008-10-30 18:28
/* * $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 |
最近读者: