springboot 报错Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported

项目默认使用POST方式提交json字符串:

    public RestResponse statusChange(@RequestBody Map<String, Object> params) {
        if(params == null){
            params = new HashMap<>();
        }
        return RestResponse.success();
    }

但是在接入其他厂商接口时,对方的数据格式是:

Content-Type: application/x-www-form-urlencoded

导致推送的数据无法获取,查询资料(Google)得知,这种数据格式key=value格式拼接的数据,可以使用@RequestParam获取数据

    public RestResponse statusChange(@RequestParam Map<String, Object> params) {
        if(params == null){
            params = new HashMap<>();
        }
        return RestResponse.success();
    }

 

posted @ 2019-11-22 16:15  华格瑞沙  阅读(1062)  评论(0编辑  收藏  举报