在一篇12年前的api说明中看到了关于本文要描述的主题的原版说明(http://www.d.umn.edu/~tcolburn/cs4531/struts/api/org/apache/struts/action/ActionServlet.html),深深的汗一把……
起因是某个运转了很多年的节点系统,使用struts1.x开发的。由于了解struts是从2开始的,知道1跟2有大的差异,那时2都有点末日红花,所以尽管当初看到这个节点系统时,对其配置的实现有些疑惑,然而并没有更进一小步的看一下ActionServlet类的实现,最近又翻开了此系统,由于一直打算写一个昨日系列的技术文,因此就拿此事作为第一篇了。
原版的配置说明:
The standard version of ActionServlet is configured based on the following servlet initialization parameters, which you will specify in the web application deployment descriptor (/WEB-INF/web.xml) for your application. Subclasses that specialize this servlet are free to define additional initialization parameters.
config - Comma-separated list of context-relative path(s) to the XML resource(s) containing the configuration information for the default module. (Multiple files support since Struts 1.1) [/WEB-INF/struts-config.xml]. config/${module} - Comma-separated list of Context-relative path(s) to the XML resource(s) containing the configuration information for the module that will use the specified prefix (/${module}). This can be repeated as many times as required for multiple modules. (Since Struts 1.1) configFactory - The Java class name of the ModuleConfigFactory used to create the implementation of the ModuleConfig interface. [org.apache.struts.config.impl.DefaultModuleConfigFactory] convertNull - Force simulation of the Struts 1.0 behavior when populating forms. If set to true, the numeric Java wrapper class types (like java.lang.Integer) will default to null (rather than 0). (Since Struts 1.1) [false] rulesets - Comma-delimited list of fully qualified classnames of additional org.apache.commons.digester.RuleSet instances that should be added to the Digester that will be processing struts-config.xml files. By default, only the RuleSet for the standard configuration elements is loaded. (Since Struts 1.1) validating - Should we use a validating XML parser to process the configuration file (strongly recommended)? [true] |
关键部分的大概翻译:
标准版的ActionServlet是基于下面的servlet初始化参数进行配置的(在/WEB-INF/web.xml内指定)。特例化的ActionServlet子类可以自由定义附加的初始化参数。 config –以逗号分隔开的xml资源文件列表(路径代表相对于当前上下文),包含默认模块的配置信息(struts1.1之后支持多个配置文件)[默认:/WEB-INF/struts-config.xml] config/${module} -以逗号分隔开的xml资源文件列表(路径代表相对于当前上下文),xml的配置信息是针块指定前缀的模块的(模块的前缀是由/${module}指定的)。(struts1.1.起可用) configFactory – 创建实现了ModuleConfig接口的类对象的ModuleConfigFactory工厂类 convertNull – 填充表单时强制模拟struts1.0的行为。若设为true包装器类型 (如java.lang.Integer)的默认值为null(而不是0)。(自 Struts 1.1)[默认:false]
|
由以上,可以看出除标准的资源配置外,你也可以使用config/${module}进行指定前缀的配置。在ActionServlet.init方法内,也可以看到对以config/开头的配置进行了初始化。