如何在WILDCARD动作映射中以单一形式处理多个动作? [英] How do I handle multiple actions in single form in WILDCARD action mapping?
问题描述
根据此解决方案 Struts2处理多个操作... 知道Struts2 DMI可以轻松处理单一形式的多个Aciton.
According this solution Struts2 handle multiple actions... I know the Struts2 DMI can handle multiple acitons in single form easily.
最近,Struts2关闭了DMI机制以解决安全问题.现在,我们使用WILDCARD MAPPINGS映射struts.xml
Recently, Struts2 turned off DMI mechanism for security issue. Now, we use WILDCARD MAPPINGS to map all actions in struts.xml
示例:
<action name="*/*" class="action.{1}Action" method="{2}">
...
</action>
在WILDARD MAPPINGS中,以单个形式处理多个动作/方法存在一个小问题.
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>
如何解决此问题?
推荐答案
在struts2中,即使DMI已关闭,仍然可以使用特殊参数action:
.要在JSP中使用此参数,您需要进行配置
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
在您的struts.xml
文件中:
<constant name="struts.mapper.action.prefix.enabled" value="true" />
当过滤器试图从过滤后的URL获取动作映射时,特殊参数由动作映射器处理,并且当您使用submit
标记的action
属性时,会将此参数添加到表单中.
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.
这篇关于如何在WILDCARD动作映射中以单一形式处理多个动作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!