问题
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 WILDARD 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?
回答1:
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.
来源:https://stackoverflow.com/questions/23491738/how-do-i-handle-multiple-actions-in-single-form-in-wildcard-action-mapping