Search code examples
struts2struts-config

How to hide the "action" extension


When user makes login then on success browser redirect to

http://appname.com/main.action How can I make so that adress line will looks like http://appname.com/main

<action name="login"
    class="user.action.LoginAction" method="execute">
    <result name="success" type="redirectAction">
        main
    </result>
    <result name="error">/login.jsp</result>
</action>

Solution

  • You must set the following property in the struts.xml :

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

    You can set different extensions, or no extension at all, that is specified with the comma for a reason, as you can read in this answer.

    It's generally used together with Advanced Wildcard Mappings,to create user-friendly pretty URLs.