Let take an example to understand methods in Action mappings
struts.xml
Here our action is mapped for same action class for two different methods, on place of execute() method we are calling takeForm() and addChart() methods on same action class for crossponding action names.
<action name="takeForm" class="blog.webideaworld.in.takeAction" method="takeForm">
<result name="success">success.jsp</result>
<result name="failure">error.jsp</result>
</action>
<action name="addChart" class="blog.webideaworld.in.takeAction" method="addChart">
<result name="success">success.jsp</result>
<result name="failure">error.jsp</result>
</action>
we can also perform above task with wildcards
struts.xml (With Wildcard)
<action name="*" class="blog.webideaworld.in.takeAction" method="{1}">
<result name="success">success.jsp</result>
<result name="failure">error.jsp</result>
</action>
The "*" in the path
attribute allows the mapping to match the request URIs with same action and method name.The part of the URI matched by the wildcard will then be substituted into various attributes of the action mapping and its action results replacing {1}.
For the rest of the request, the framework will see the action mapping and its action results containing the new values.
No comments:
Post a Comment