Struts2以单一形式处理多个动作 [英] Struts2 handle multiple actions in single form
本文介绍了Struts2以单一形式处理多个动作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个包含三个按钮print
/export
/save
的表单.
I have a form contains three buttons print
/export
/save
.
<s:form action="/userAction">
<s:submit type="image" value="%{'print'}" src="/print.png" />
<s:submit type="image" value="%{'export'}" src="/export.png" />
<s:submit type="image" value="%{'save'}" src="/save.png" />
</s:form>
如何在struts.xml
中对此进行映射?
How can I map this in struts.xml
?
推荐答案
在struts.xml
中,操作是通过<action
标记
<action name="userAction" class="...
提交按钮应包含method
属性,以调用相应的操作方法
the submit buttons should include method
attribute to call corresponding methods of the action
<s:submit type="image" value="%{'print'}" src="/print.png" method="print" />
<s:submit type="image" value="%{'export'}" src="/export.png" method="export" />
<s:submit type="image" value="%{'save'}" src="/save.png" method="save" />
这篇关于Struts2以单一形式处理多个动作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文