【发布时间】:2018-05-07 22:06:06
【问题描述】:
我正在尝试绑定与 AJAX 调用中的其他数据一起序列化的表单数据。我似乎无法让 Spring 把它捡起来。它只是实例化一个空表单。
JavaScript:
$.ajax({
method: "GET",
url: contextPath,
data: {"form": serializedForm, "otherStuff": otherStuff},
contentType:"application/json; charset=utf-8",
cache: false,
success: function(data) {});
控制器:
@ResponseBody
@RequestMapping(value="/blah", method=RequestMethod.GET)
public String blah(@ModelAttribute("form") Form form, @RequestParam(value="otherStuff[]", required=false) String[] otherStuff, HttpServletResponse response){
//stuff
}
有没有办法让 Spring 在方法参数中映射我的表单?
似乎我可以从 HttpServletRequest 中单独获取参数,但理想情况下我希望我的表单通过 InitBinder。
【问题讨论】:
标签: javascript ajax spring spring-3