【问题标题】:How to send x-editable request to spring mvc backend?如何向spring mvc后端发送x-editable请求?
【发布时间】:2015-01-27 19:29:18
【问题描述】:

我想在我的页面中使用 x-editable,我向 this document 学习。

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 "";
}

但是,我一次又一次地得到错误,错误信息是这样的:

{"timestamp":1417250586743,"status":400,"error":"Bad 请求","异常":"org.springframework.web.bind.MissingServletRequestParameterException","消息":"必填 字符串参数“displayName”不是 present","path":"/candidates/updateDisplayName"}

我知道这是由请求参数引起的,但不知道如何解决,有人可以帮忙吗?非常感谢。

【问题讨论】:

    标签: java spring spring-mvc thymeleaf x-editable


    【解决方案1】:

    我在 @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 "";
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-01-06
      • 2020-07-07
      • 2019-07-17
      • 1970-01-01
      • 2019-07-19
      • 2018-08-07
      • 2019-12-22
      • 1970-01-01
      相关资源
      最近更新 更多