Explanation of “.action” extention significance in Struts2 URL

試著忘記壹切 提交于 2019-12-08 05:47:23

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/17568187/explanation-of-action-extention-significance-in-struts2-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!