springboot 接收参数,解析json出现错误:was expecting 'null', 'true', 'false' or NaN

错误信息

converter.HttpMessageNotReadableException: JSON parse error: Unrecognized token 'token': was expecting 'null', 'true', 'false' or NaN; nested exception is com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'token': was expecting 'null', 'true', 'false' or NaN

后端接收方法-参数接受

    @PostMapping("/doLogin")
    public String login(@RequestBody Map map, HttpSession session){
        try {
            String account = map.get("account")==null?"":map.get("account").toString();
            String password = map.get("password")==null?"":map.get("password").toString();

请求方法



错误信息是400,如下所示:

springboot 接收参数,解析json出现错误:was expecting 'null', 'true', 'false' or NaN_第1张图片
参数是用等号连接的。
加入JSON.stringify()对传参进行解析;代码如下。




后端可以正常接收了。

springboot 接收参数,解析json出现错误:was expecting 'null', 'true', 'false' or NaN_第2张图片

你可能感兴趣的:(Java)