- pom.xml 加入apache的依赖
@Bean public MultipartResolver resolver() { return new CommonsMultipartResolver(); }
@PostMapping("/uploadFile") @ResponseBody public Map<String, Object> uploadFile(@RequestParam("file") MultipartFile file) throws IOException { String originalFilename = file.getOriginalFilename(); file.transferTo(new File("d:/" + originalFilename)); Map<String, Object> map = new HashMap<>(); map.put("code", 1); return map; }
- 上传方法进不去,就是因为没有加那个resolver
网友评论