How to remove the action suffix extension in Struts 2
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







When i remove the extension then css files are served as text/html MIME type
How to add the action suffix extension in Struts 2 with tiles ?
I tested in struts 2 but if i am using tiles that i can’t
the web.xml, filter url-pattern needs to be updated accordingly. Thanks.
I’m facing the same problem. Any Ideas?
I’m using struts 2.1.6 and the html extension works but the empty extension doesn’t it gives an error that the namespace / can’t find the corresponding action, any idea why?
[...] The default .action is configurable, just change the “struts.action.extension” value to suit your [...]