是否有可能从Java HTTPServletRequest中检索表单名称? [英] Is it possible to retrieve the form name from a Java HTTPServletRequest?

查看:145
本文介绍了是否有可能从Java HTTPServletRequest中检索表单名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获取用于从Java HTTPServletRequest对象发布参数的表单名称。这可能吗。我没有看到任何看起来像它会返回给我的方法。

I would like to get the name of the form used to post parameters from a Java HTTPServletRequest object. Is this possible. I don't see any method that looks like it will return it to me.

推荐答案

HTML表单名称不作为部分提交的请求。如果您需要它(为什么?),您可以将其作为隐藏输入提交:

HTML form name is NOT submitted as part of the request. If you need it (why?) you can submit it as hidden input instead:

<form name="myForm" action="/my_servlet">
  <input type="hidden" name="htmlFormName" value="myForm"/>
  ...

在您的servlet中:

In your servlet:

String htmlFormName = request.getParameterValue("htmlFormName");

这篇关于是否有可能从Java HTTPServletRequest中检索表单名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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