struts2xml-configurationstruts2-convention-plugindeployment-descriptor

How to remove .action from URL without using a constant in struts.xml


I am using Struts 2 convention plugin. I don't want to use any XML based configurations in my application. So, in this case, how how to remove .action extension from URL without using <constant name="struts.action.extension" value="" /> in struts.xml? I am currently using struts.xml file only to remove .action extension. Is there any annotation to remove .actionextension?


Solution

  • There isn't such annotation. You can use struts.properties or define a constant in web.xml like

    <filter>
        <filter-name>struts2</filter-name>
        <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
        <init-param>
            <param-name>struts.action.extension</param-name>
            <param-value>,</param-value>
        </init-param>
    </filter>