开发者

is struts controller creats the action objectes when reading struts-config.xml file?

  1. what does it means "struts controller reads the struts-config.xml file" when ever web application is started?

  2. is controller create action objects while reading the struts-config fi开发者_开发问答le?


when struts reads in the file it is only parsing it and loading the action definitions. The only errors you will get are XML parsing errors. Not sure about Struts 2, but in struts 1 it will not validate that the objects or the forwarded targets exist or compile. That is a runtime check


is controller create action objects while reading the struts-config file

I think it does that lazily (when the URL is accessed). At least Struts1 does.


1. what does it means "struts controller reads the struts-config.xml file" when ever web application is started?

The "read" means that Struts will parse the XML file and create object representations of the tags you have declared inside (e.g. the ActionMapping reflects an <action> tag). These objects will then be used whenever Struts needs to know different configuration information avoiding the need to do costly I/O operations to go to the XML file each time.

The class that contains the rules for parsing the file is org.apache.struts.config.ConfigRuleSet (javadoc: The set of Digester rules required to parse a Struts configuration file (struts-config.xml)).

2. is controller create action objects while reading the struts-config file?

No, this is done later, when a request comes in.

When a request comes in, Struts tries to find an already existing Action instance that matches the URL path. If it finds it, it returns it, else it will create it and store it for later use before returning it.

The RequestProcessor.processActionCreate method does this (javadoc: return an Action instance that will be used to process the current request, creating a new one if necessary).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜