我想在我的页面中使用x-editable,我从这个文档中学到了它。
html 元素在这里:
<a href="#" id="displayName" name="displayName" data-type="text" data-pk="1" data-url="/candidates/updateDisplayName" data-title="Enter username" th:text="${displayName}">Click and input</a>
我的控制器是:
@RequestMapping(value = "/candidates/updateDisplayName", method = RequestMethod.POST)
public @ResponseBody String updateDisplayName(@RequestParam(value = "displayName") String displayName, HttpServletRequest request) {
System.out.println("Update display name");
System.out.println(displayName);
return "";
}
但是,我一次又一次地收到错误,错误消息如下:
{"时间戳":1417250586743,"状态":400,"错误":"错误 请求","异常":"org.springframework.web.bind.MissingServletRequestParameterException","message":"Required 字符串参数"显示名称"不是 present","path":"/candidate/updateDisplayName"}
我知道这是由请求参数引起的,但不确定如何解决,任何人都可以帮忙吗? 多谢。
我在它工作@RequestParam将"displayName"更改为"name",感谢chrome开发人员工具,它对我有帮助。
@RequestMapping(value = "/candidates/updateDisplayName", method = RequestMethod.POST)
public @ResponseBody String updateDisplayName(@RequestParam(value = "name") String displayName, HttpServletRequest request) {
System.out.println("Update display name");
System.out.println(displayName);
return "";
}