title: Force Download CSV from Spring Controller
body: <p>Follow up question from my <a href="https://stackoverflow.com/questions/29461909/spring-controller-not-returning-file/29462448?noredirect=1#comment47096755_29462448">last issue</a> which has since been resolved. </p>
  
  <p>I'm trying to download a file via a Spring <code>@Controller</code> by returning a <code>FileSystemResource</code>. I receive a valid HTTP 200 Response and can view all of the file's content in the browser, however I never receive the prompt to download the file. Here's my method:</p>
  
  <pre><code>@RequestMapping(method = RequestMethod.GET, headers="Accept=*/*", value = "/download/{fileName:.+}", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
  @ResponseBody
  public FileSystemResource download(@PathVariable String fileName, HttpServletResponse response) throws IOException {
      File file = new File(path + '/' + fileName);
      response.setContentLength((int)fileName.length());
      response.setContentType("application/force-download");
      response.setHeader("Content-Disposition","attachment; filename=\"" + fileName + "\"");//fileName);
      return  new FileSystemResource(file);
  }
  </code></pre>
  
  <p>From the browser: </p>
  
  <pre><code>Response Headers
  Content-Disposition | attachment; filename="my_data.CSV"
  Content-Length  | 1712
  Content-Type    | text/csv
  
  Request Headers
  Accept          | */*
  Accept-Encoding | gzip, deflate
  Accept-Language | en-US,en;q=0.5
  </code></pre>
  
  <p>Everything appears valid here; any idea why the actual file isn't getting returned?  Cheers</p>