我正在使用 Spring Boot、JSP 和 MSSQL 上传和下载文件。我可以运行上传和下载功能,但从数据库下载的文件已损坏。谁能帮我这个?
这是我的春季版本
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.0.3-SNAPSHOT</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
Run Code Online (Sandbox Code Playgroud)
我的控制器
@RequestMapping(value = "/uploadFile", method = RequestMethod.POST)
public ResponseEntity < Object > upload(@RequestPart(required = false) MultipartFile file) throws IOException {
try {
if (file != null) {
tmDAO.storeFile(file, tm);
}
return new ResponseEntity < Object > ("success", HttpStatus.OK);
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
@RequestMapping("/downloadFile/{id}")
public String downloadFile(@PathVariable("id") String id,
HttpServletResponse res) throws IOException {
FileModel …Run Code Online (Sandbox Code Playgroud)