[昨日技術]struts1.x中ActionServlet的config/${module}配置說明

版權聲明:本文爲博主原創文章,但是你也可以隨意轉載。 https://blog.csdn.net/smartcore/article/details/78712578

在一篇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/開頭的配置進行了初始化。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章