Question

I'm new to Struts 2 overall and would like to know, if there is a way to get a list of all the namespaces and actions for each namespace that is defined in the xml?

I have a package and I am including configurations for each namespace:

<include file="struts_someNamespace1.xml" />
<include file="struts_someNamespace2.xml" />
<include file="struts_someNamespace3.xml" />

Each of those XML files is defined similar to this (this has less code):

 <package name="somePackage"  namespace="/someNamespace1" extends="default">
     <action name="firstAction" class="com.someAction">
        <interceptor-ref name="defaultStack"/>
        <interceptor-ref name="json">   </interceptor-ref>
        <result type="json">        </result>
     </action>
     <action name="secondAction" class="com.otherAction">
        <interceptor-ref name="defaultStack"/>
        <interceptor-ref name="json">   </interceptor-ref>
        <result type="json">        </result>
     </action>
 </package>

Is there a way using some utility class where I can get a list or of each namespace and its actions?

Example Results (in JSON)

{
    "someNamespace1": ["firstAction","secondAction"}, 
    "someNamespace2": ["about","home"]
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top