如果我有以下 HTML 表单:
<form id="myForm" action="/myFormHandler" method="post">
<input type="hidden" id="fizz-id" name="fizz" value="3" />
<input type="hidden" id="buzz-id" name="buzz" value="6" />
</form>
(注意没有提交按钮)。然后我有以下 jQuery:
$("#someButton").click(function() {
$("#myForm").submit();
});
然后在服务器端(Spring MVC 控制器),是否将隐藏字段id或名称发送到处理程序方法?
@RequestMapping(value = "/myFormHandler.html", method = RequestMethod.POST)
public ModelAndView handleMyForm(
@RequestParam("fizz-id") String fizz,
@RequestParam("buzz-id") String buzz) {
// Should I be looking for "fizz-id" or "fizz"???
}
提前致谢。