您的位置:首页 > 编程语言 > Java开发

How to remove the action suffix extension in Struts 2

2015-09-17 09:57 666 查看
In Struts 2, all action class has a default suffix
.action
extension. For example,

<struts>
<package name="default" namespace="/" extends="struts-default">
<action name="SayStruts2">
<result>pages/printStruts2.jsp</result>
</action>
</package>
</struts>


To access the “
SayStruts2
″ action class, use the following URL :

Action URL : http://localhost:8080/Struts2Example/SayStruts2.action

Configure the action extension

Struts 2 is allow to configure the action extension easily, to change it, just declare a constant “
struts.action.extension
” value :

1. html extension

Change the action class to
.html
extension.

<struts>

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

<package name="default" namespace="/" extends="struts-default">
<action name="SayStruts2">
<result>pages/printStruts2.jsp</result>
</action>
</package>

</struts>


Now you can access the “
SayStruts2
″ action class via

Action URL : http://localhost:8080/Struts2Example/SayStruts2.html

2. No extension

Change the action class to empty extension.

<struts>

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

<package name="default" namespace="/" extends="struts-default">
<action name="SayStruts2">
<result>pages/printStruts2.jsp</result>
</action>
</package>

</struts>


Now you can access the “
SayStruts2
′ action class via

Action URL : http://localhost:8080/Struts2Example/SayStruts2
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  struts struts2.0