title: How to download files properly using FileSystemResource in Spring?
body: <p>I have this following code for downloading files :-</p>
  
  <pre><code>@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);
  
      }
  
  }
  </code></pre>
  
  <p>When I go to the link for the first time nothing is displayed .When I reload only a text file with name f.txt is downloaded instead of the pdf file. I want the pdf file to be displayed in the browser. How to solve this problem ?</p>