SpringCloud中接收application/json格式的post请求参数并转化为实体类

@CrossOrigin(allowCredentials="true", allowedHeaders="*", methods={RequestMethod.GET,  
            RequestMethod.POST, RequestMethod.DELETE, RequestMethod.OPTIONS,  
            RequestMethod.HEAD, RequestMethod.PUT, RequestMethod.PATCH}, origins="*")
    @RequestMapping(value="/save",method={RequestMethod.POST})
    public String save(@RequestBody PostColumn entity) {
        String json = tableService.save(entity.getSchame(),entity.getTablename(),entity.getColumnname(),entity.getRemark());
        logger.info(json);
        return json;
    }

这里一定要在实体类之前加上@RequestBody

原文地址:https://www.cnblogs.com/wpcnblog/p/9026345.html