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

邮差的信 提交于 2021-02-08 06:59:24

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!