spring boot后端使用fastjson,错误代码415, 500

$.post({
url: "/register",
dataType: "json",
contentType: "application/json",
data: JSON.stringify(info),
success: function (data) {

}
});

必须包含:

dataType: "json",           
contentType: "application/json", 不加后端会出现415错误

spring boot代码如下
@PostMapping("/register")
    @ResponseBody
    public String register(@RequestBody JSONObject info) {
        return null;  
   }

必须加@RequestBody  不然出现 500错误

猜你喜欢

转载自www.cnblogs.com/destinymingyun/p/11026699.html
今日推荐