问题原来是我调用该方法的方式。我的ajax代码正在传递请求正文中的所有参数,而不是将其作为请求参数传递,这就是为什么我的
@RequestParam参数都为空的原因。我将ajax代码更改为:
$.ajax({ type: 'POST', url: "/comments/add.page?uuid=${param.uuid}&type=${param.type}", data: text, success: function (data) { // }});我还更改了控制器方法以从请求正文中获取文本:
@RequestMapping(value = "add.page", method = RequestMethod.POST)@ResponseBodypublic Object createComment( @RequestParam(value = "uuid", required = false) String entityUuid, @RequestParam(value = "type", required = false) String entityType, @RequestBody String text, HttpServletResponse response) {现在,我得到了期望的参数。



