简体   繁体   English

是否可以从Java HTTPServletRequest中检索表单名称?

[英]Is it possible to retrieve the form name from a Java HTTPServletRequest?

I would like to get the name of the form used to post parameters from a Java HTTPServletRequest object. 我想获取用于从Java HTTPServletRequest对象发布参数的表单的名称。 Is this possible. 这可能吗。 I don't see any method that looks like it will return it to me. 我没有看到任何看起来会将它返回给我的方法。

HTML form name is NOT submitted as part of the request. HTML表单名称不作为请求的一部分提交。 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"/>
  ...

In your servlet: 在你的servlet中:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM