2个按钮上述< S:形式>决定动作类 [英] 2 buttons in <s:form> to decide the action class

查看:133
本文介绍了2个按钮上述< S:形式>决定动作类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能做这样的事情?

Is it possible to do something like this?

<s:form action="formAction1" namespace="/form1">
<s:form action="formAction2" namespace="/form2">
<s:textfield name="user"/>
<s:password name="pwd" />
<s:submit name="sub1" value="start1">
<s:submit name="sub2" value="start2">
</s:form>
</s:form>     

即。如果我点击启动1 按钮,然后 formAction1 将被提交。
否则点击 START2 时,那么 formAction2 将被提交。
其实我想有 2种不同的动作 2不同的按钮 单一形式
我不想使用网址&LT; - S:!网址 - &GT; 标签

i.e. if I click start1 button, then formAction1 will be submitted. else when start2 is clicked, then formAction2 will be submitted. Actually I want to have 2 different actions on 2 different buttons in a single form. I Don't want to use url <!-- s:url --> tag.

推荐答案

不,这不可能在HTML中,也不在Struts2的。你不应该有嵌套形式,但你可以在页面上使用的几种形式。

No, it's not possible in HTML, nor in Struts2. You should not have nested forms, but you can use several forms on the page.

<s:form>
 <s:textfield name="user"/>
 <s:password name="pwd" />
 <s:submit name="sub1" value="start1" action="formAction1">
 <s:submit name="sub2" value="start2" action="formAction2">
</s:form>

另请参阅如何对齐两个提交按钮?。还有信息如何Struts2的配置用行动preFIX。

Also see How to align two submit buttons?. There's also information how to configure Struts2 to use action prefix.

这篇关于2个按钮上述&lt; S:形式&GT;决定动作类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆