url mapping - Reuse method defined under another xml Struts2 -
here sample 2 xmls.
email.xml:
<action name="mailselect" class="com.my.emailaction"> <result name="success">mailselect.jsp</result> </action>
i want use same method call defined in email.xml in xml.
another.xml:
<action name="mailselect" class="com.my.emailaction"> <result name="success">/email/mailselect.jsp</result> </action>
when tried call, action being called http://localhost:8080/test/web/another/mailselect
instead of correct http://localhost:8080/test/web/email/mailselect
.
any way reuse same method in xml?
to make sure action names don't clashes should configure them in different namespaces.
<package name="email" namespace="/web/email" extends="struts-default"> <action name="mailselect" class="com.my.emailaction"> <result name="success">/email/mailselect.jsp</result> </action> </package> <package name="another" namespace="/web/another" extends="struts-default"> <action name="mailselect" class="com.my.emailaction"> <result name="success">mailselect.jsp</result> </action> </package>
for better understanding namespaces @ struts 2 namespace configuration example , explanation tutorial.
Comments
Post a Comment