项目目的:
使用MultipartFile接收http post传进来的图片,Controller中把接收到的图像转换为File对象给后续程序使用。
代码实现:
SpringBoot MVC接收外部传入的图片,强转失败。代码如下:
@PostMapping("/parseImage") public String parseImage(HttpServletRequest request, @RequestParam MultipartFile[] uploadFiles) throws IOException, ServletException { StandardMultipartHttpServletRequest req = (StandardMultipartHttpServletRequest) request; int fileSize = uploadFiles.