简体   繁体   中英

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. 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. 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:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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