Struts 2のアクション接尾辞拡張を削除する方法
ダウンロードする – リンク://wp-content/uploads/2010/06/Struts2-Custom-Extension-Example.zip[Struts2-Custom-Extension-Example.zip]
Struts 2では、すべてのアクションクラスにデフォルトの
接尾辞.action拡張子
が付きます。
例えば、
<struts> <package name="default" namespace="/" extends="struts-default"> <action name="SayStruts2"> <result>pages/printStruts2.jsp</result> </action> </package> </struts>
「SayStruts2」アクションクラスにアクセスするには、次のURLを使用します。
Action URL : http://localhost:8080/Struts2Example/SayStruts2.action
アクション拡張を設定する
Struts 2では、アクション拡張を簡単に構成することができます。変更するには、定数 ”
struts.action.extension
“の値を宣言するだけです。
1. htmlの拡張子
アクションクラスを.html拡張子に変更します。
<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>
これで、 “SayStruts2″アクションクラスにアクセスできます。
Action URL : http://localhost:8080/Struts2Example/SayStruts2.html
2.拡張子なし
アクションクラスを空の拡張に変更します。
<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>
これで「SayStruts2」アクションクラスにアクセスできます
Action URL : http://localhost:8080/Struts2Example/SayStruts2