标签:method framework pos not 框架 support spring 代码 public
使用IDEA开发springboot项目,需求中要提交数据项和文件上传,同时接收实体bean对象和文件,后台Controller接收配置方式:
Controller代码如下:
1 @RequestMapping(value="/comment",method = RequestMethod.POST) 2 public @ResponseBody RetResult saveIndustryComment(HttpServletRequest request,@RequestParam("uploadFile")MultipartFile uploadFile,@RequestBody Comment commentBean){ 3 4 //业务逻辑 5 .... 6 }
使用Postman工具测试时报如下异常:org.springframework.web.HttpMediaTypeNotSupportedException: Content type ‘multipart/form-data;
解决方案:去掉@RequestBody注解就可以了
1 @RequestMapping(value="/comment",method = RequestMethod.POST) 2 public @ResponseBody RetResult saveIndustryComment(HttpServletRequest request,@RequestParam("uploadFile")MultipartFile uploadFile,Comment commentBean){ 3 //业务逻辑
4 }
标签:method framework pos not 框架 support spring 代码 public
原文地址:https://www.cnblogs.com/front-end-develop/p/12534224.html