Is it possible to retrieve the form name from a Ja

2019-01-26 17:28发布

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.

1条回答
做个烂人
2楼-- · 2019-01-26 17:33

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");
查看更多
登录 后发表回答