質問

This might be a useless or lame question but please explain me this.

In struts2 when we assign an action to a form button and click on that button, that action is called. Now, when the result of the action file is displayed, the URL in browser shows

localhost:8080/HelloWorld/ClassName.action

Sometimes by default .action part doesn't show. But both works the same.

I am required to explain to someone what is significance of this .action. Why is that extension shown in URL and is there some specific thing which enables and disables the .action in Struts2 URL?

役に立ちましたか?

解決

If the default action mapper is used to get the mapping from the request url it uses the action extension to determine the action name part. The action extension could be configured with the constant in struts.xml (or struts.properties)

<constant name="struts.action.extension" value="action,,"/> 

that is default. In some cases if you need to access the static resources instead of action under the same path you could use the ".action" extension to distinguish action from the static resource. If you don't have or don't use such resources then you could easily suppress it by removing action from the configuration above.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top