title: Downloading Files added into database in Angularjs and Spring mvc
body: <p>I am facing an issue while downloading the file added into the database. I am using AngularJS and Spring MVC architecture.
  In a table I am displaying filenames I have added.</p>
  
  <p>Here is my html</p>
  
  <p>fee.html</p>
  
  <pre><code>    &lt;td&gt;&lt;a href="./filedownload/{{fee.fileName}}/feespath"&gt;
      {{fee.fileName}}&lt;/a&gt;&lt;/td&gt;
  </code></pre>
  
  <p>Here is Spring Controller.java</p>
  
  <pre><code>    @RequestMapping(value="/filedownload/{fileName:.+}/{path}",method=
      {RequestMethod.GET,RequestMethod.POST})
      public void filedownload(@PathVariable String 
      fileName,@PathVariable String path,HttpServletResponse response)
      {
      Path file = Paths.get(context.getRealPath("/"+path+"/"),
      fileName);
      if (Files.exists(file)) 
      {
          response.setContentType("*/*");
          response.addHeader("Content-Disposition", "attachment;
          filename="+fileName);
      try
      {
          Files.copy(file, response.getOutputStream());
          response.getOutputStream().flush();
      } 
      catch (IOException ex) 
      {
          ex.printStackTrace();
      }
      }
      }
  </code></pre>
  
  <p>And while adding I am using "feespath" as the path name that I am using in my html. Here is how I am creating a path by name feespath</p>
  
  <pre><code>    @RequestMapping(value="/uploadFeeFiles",method=
      {RequestMethod.GET,RequestMethod.POST})
      public @ResponseBody String uploadFeeFiles(HttpServletRequest 
      request,HttpServletResponse response,MultipartHttpServletRequest 
      mRequest,Principal principal)
      {
          String status="";
      try
      {
          mRequest = (MultipartHttpServletRequest) request;
          mRequest.getParameterMap();
          Iterator&lt;String&gt; itr = mRequest.getFileNames();
      while (itr.hasNext()) 
      {
          MultipartFile file = mRequest.getFile(itr.next());
          String fileName = 
          uploadPathService.getFilesPath(file,"feespath");
          status = fileName;
      }
      } 
      catch (Exception e) 
      {
          e.printStackTrace();
      }
          return status;
      }
  </code></pre>
  
  <p>I am able to display file names correctly in the table but if I click on it it's redirecting to a blank page with url</p>
  
  <p><a href="http://localhost:8080/MyProject/filedownload/12802889_1263849593630301.jpg/feespath" rel="nofollow noreferrer">http://localhost:8080/MyProject/filedownload/12802889_1263849593630301.jpg/feespath</a></p>
  
  <p>So I am not able to figure it out. If anyone can introduce some ideas, I'll be very helpful.</p>