title: How to return a text file with Spring MVC?
body: <pre><code>@RequestMapping( method = RequestMethod.POST, value = DataController.RESOURCE_PATH + "/file", headers = "content-type=application/json" )
  @ResponseBody
  public void export( @RequestBody JSONObject json, HttpServletResponse response ) throws IOException
  {
      String myString = "Hello";
  }
  </code></pre>
  
  <p>The string is generated inside the <code>Controller</code>.
  What I want is to send back to the user a Window where he can save a file which contains the <code>myString</code>.</p>
  
  <pre><code>$.ajax({
      type: "POST",
      url: url,
      data: JSON.stringify(createJSON()),
      contentType: "application/json",
      success: function(response)
      {
          console.log("Exported JSON: " + JSON.stringify(createJSON()));
          console.log(response);
      },
      error: function()
      {
          console.log(arguments);
          alert("Export process failed.");
      }
  });
  </code></pre>
  
  <p>It clearly doesn't work in this current state and I am stuck at the moment.</p>