【发布时间】:2021-09-16 17:20:43
【问题描述】:
我有以下上传控制器,它有两个不同类型的参数:1 是文件将被保存到的路径和 2 文件本身。我在看 为正确的方法定义而不是 2 @Requestparam 在 STS 中给出错误。
@PostMapping("/{path}/")
public String handleFileUpload(@RequestParam("path"), @RequestParam("file") MultipartFile file,
RedirectAttributes redirectAttributes) {
filesStorageService.store(file);
redirectAttributes.addFlashAttribute("message", "You successfully uploaded " + file.getOriginalFilename() + "!");
return "redirect:/";
}
【问题讨论】:
-
路径可以使用
@PathVariable("path") String path作为参数
标签: spring-boot rest spring-restcontroller