javajspstruts2wildcard-mappingdmi

How do I handle multiple actions in single form in wildcard action mapping?


According this solution Struts2 handle multiple actions... I know the Struts2 DMI can handle multiple acitons in single form easily.

Recently, Struts2 turned off DMI mechanism for security issue. Now, we use Wildcard Mappings to map all actions in struts.xml

Example:

<action name="*/*" class="action.{1}Action" method="{2}">
    ...
</action>

In Wildcard Mappings, it has a little problem to deal with mapping multiple actions/methods in single form.

<s:form action="actionA/method2" theme="simple" >
    <s:submit value="lastStep"  action="actionA/method1"/>
    <s:submit value="nextStep" />
</s:form>

How can I fix this problem?


Solution

  • In Struts2 even if DMI is turned off still possible to use special parameter action:. To use this parameter in JSP you need to configure

    in your struts.xml file:

    <constant name="struts.mapper.action.prefix.enabled" value="true" />
    

    Special parameters are handled by the action mapper when filter is trying to get action mapping from the filtered URL, and this parameter is added to the form when you use action attribute of the submit tag.