本文介绍了确定使用哪个提交按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以确定使用哪个提交按钮?我有一个带有2个提交按钮的确认表单。第一个将确认订单,执行一些数据库任务,然后重定向。第二个是取消按钮,只是重定向到同一页面,而不执行任何数据库任务。

在servlet中是否可能,最好是通过请求对象,以确定使用哪个提交按钮?我宁愿不要依赖Javascript,因为这很简单,但如果唯一的可能性会采用它。



谢谢。

解决方案

< button name =someNamevalue =someValuetype =submit> Submit< /按钮>
< button name =otherNamevalue =otherValuetype =submit>取消< / button>

您将拥有 someName = someValue otherName = otherValue 在您的请求数据中


Is it possible to determine which submit button was used? I have a confirmation form with 2 submit buttons. The first would confirm the order, do some DB tasks, then redirect. The second, which is a Cancel button, will just redirect to the same page, without doing any DB tasks.

Is it possible in the servlet, preferably via the request object, to determine which submit button was used? I'd prefer not to be dependent on Javascript, as that is pretty simple, but will resort to it if the only possibility.

Thanks.

解决方案
<button name="someName" value="someValue" type="submit">Submit</button>
<button name="otherName" value="otherValue" type="submit">Cancel</button>

You'll have someName=someValue or otherName=otherValue in your request data

这篇关于确定使用哪个提交按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 03:48