我已經下載該文件下面的代碼: -如何在Spring中使用FileSystemResource正確下載文件?
@Controller
public class FileController {
@RequestMapping(value = "/files/{file_name:.+}", method = RequestMethod.GET)
@ResponseBody
public FileSystemResource getFile(@PathVariable("file_name") String fileName) {
return new FileSystemResource("C:/Users/sourav/fileServer/"+fileName);
}
}
當我去的鏈接,第一次沒有任何顯示。當我重新加載只是一個文本文件名f.txt代替下載的pdf文件。我想要在瀏覽器中顯示PDF文件。如何解決這個問題呢 ?
我有同樣的問題,使用Spring 4.3.4 – yglodt