@RequestMapping(value = "databoardDownload.do", method = RequestMethod.GET)

public void databoardDownload(String file, HttpServletRequest request,

        HttpServletResponse response) throws IOException{

     response.setHeader("Content-Disposition", "attachment;filename="+file);

     String fullPath = request.getSession().getServletContext().getRealPath("/resources/upload/databoard/" + file );

      FileInputStream fi = new FileInputStream(fullPath);

      ServletOutputStream sout = response.getOutputStream();

      byte[] buf = new byte[1024];

      int size = 0;

      while((size = fi.read(buf, 0, 1024))!=-1){

         sout.write(buf, 0, size);

      }

      fi.close();

      sout.close();

  

}

'Computer > Spring Maven MyBatis' 카테고리의 다른 글

Spring Mybatis 기본설정  (0) 2014.09.26
Spring 게시판 페이지  (0) 2014.08.18
Spring GET방식 한글 깨짐  (0) 2014.08.18
Spring 파일 업로드  (0) 2014.08.18
Mybatis ResultMap con  (0) 2014.08.13

+ Recent posts