Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Info

The example code for this tutorial, wildcard_method_selection, is available for checkout at https://svngithub.apache.org/repos/asf/struts/sandbox/trunk/struts2examples/com/apache/struts-examples

Introduction

In this tutorial we'll cover how to configure an action node in the struts.xml configuration file so that one action node can be used to relate several different Action URLs to specific methods of the Action class. This will reduce the number of action nodes we must write in the struts.xml configuration file.

...

Code Block
xml
titleStruts.xml Action Configuration
xml


<action name="createPerson" class="org.apache.struts.tutorials.wildcardmethod.action.PersonAction" method="create">
  <result name="input">input.jsp</result>
  <result name="success">view.jsp</result>
</action>

<action name="editPerson" class="org.apache.struts.tutorials.wildcardmethod.action.PersonAction" method="edit">
  <result name="input">input.jsp</result>
  <result name="success">view.jsp</result>
</action>

...

Code Block
xml
titleStruts.xml Action Configuration Using Wildcard Method Selection
xml


<action name="*Person" class="org.apache.struts.tutorials.wildcardmethod.action.PersonAction" method="{1}">
  <result name="success">view.jsp</result>
  <result name="input">input.jsp</result>
</action>

...