Search code examples
struts2

Is there any way to map action on struts2 namespace root?


I have a namespace in struts.xml

<package name="mobile" namespace="/mobile" extends="mainApp">
    <action name="abc" class="x.y.Abc"
        method="abc">
        <result name="input">/blank.html</result>
            <result name="success">/blank.html</result>
        </action>
</package>

I want to map localhost/myApp/mobile/ with the action abc

I don't mind localhost/myApp/mobile/* getting mapped with the action abc

is there any way to meet this requirement?


Solution

  • I want to fire an action on localhost:8080/appname/namespace/ i.e. namespace slash

    After slash should be action name and if it's empty you should configure empty action name.

    <package name="mobile" namespace="/mobile" extends="mainApp">
        <action name="" class="x.y.Abc"
            method="abc">
            <result name="input">/blank.html</result>
                <result name="success">/blank.html</result>
            </action>
    </package>