Java Struts | How to remove the action extension in Struts 2 framework

|
| By Webner

In struts.xml file of your web project, replace value for constant named “struts.action.extension” to as shown below :

<struts>
<constant name = "struts.action.extension" value=",">
</constant> <!-- we have set value for this constant to comma that means no extension as suffix like “ admin.action “ is required to call any action, if constant not present add it -->
<constant name = "struts.enable.DynamicMethodInvocation" value="false" />
<constant name = "struts.ui.theme" value="simple" />
<constant name = "struts.custom.i18n.resources" value="ApplicationResources" />

<package name= "default" extends= "struts-default" >
<action name ="admin" class="classpath" method="getDashboard">
<interceptor-ref name="defaultStack" />
<result name ="success"> admin.jsp </ result >
</ action>
</package>

</struts>

With above changes, we can now call admin action as below :
http://localhost:8080/SampleProject/admin

One comment

  1. Spring provides its own web framework , while at the same time providing integration with a number of popular third party web frameworks. Many thanks for sharing this.

Leave a Reply

Your email address will not be published. Required fields are marked *