Deserializing json array in Spring MVC controller

后端 未结 3 1154
滥情空心
滥情空心 2021-01-19 14:33

I am sending a list of json object and trying to deserialize it in my Spring controller. But all the time I am getting error of \'Bad request\' and results into a status co

3条回答
  •  攒了一身酷
    2021-01-19 15:06

    I will not suspect server side binding error yet because you are getting 415 - Unsupported Media Type error. You are setting correct media type on controller and hence server side is looking good.

    At client side, Please make sure you are using jquery 1.5+ to make sure beforeSend() method is getting invoked.

    Easier way to content type will be,

    $.ajax({
            url:api,
            ....
            contentType: "application/json"
        });
    

    Please inspect network request from browser and make sure content type is set in header.

    If you receive 400-Bad Request, then you can start looking deserializing issues.

提交回复
热议问题