@RequestMapping("download")
        public void download(HttpServletResponse res) throws IOException {
            OutputStream os = res.getOutputStream();
            try {
                res.reset();
                res.setHeader("Content-Disposition", "attachment; filename=dict.txt");
                res.setContentType("application/octet-stream; charset=utf-8");
                os.write(FileUtils.readFileToByteArray(getDictionaryFile()));
                os.flush();
            } finally {
                if (os != null) {
                    os.close();
                }
            }
        }

 

 

 @RequestMapping(value = "/conf/confdwn.json", method = RequestMethod.GET)
    public void downloadConf(HttpServletResponse response, Integer id) throws IOException {
        long start = System.currentTimeMillis();

        response.reset();
        response.setHeader("Content-Disposition", "attachment; filename=" + conf.getName()
                                                  + ".json");
        response.setContentType("application/octet-stream; charset=utf-8");
        response.getWriter().write(conf.getValue());
        response.flushBuffer();

        long end = System.currentTimeMillis();
        System.out.println("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<used time:" + (end - start));
    }

 

http://www.iteye.com/topic/1125784

 

相关文章:

  • 2021-08-21
  • 2022-12-23
  • 2018-05-16
  • 2021-10-14
  • 2021-04-03
  • 2021-06-10
  • 2021-11-28
猜你喜欢
  • 2017-12-21
  • 2021-12-28
  • 2021-12-10
  • 2021-05-18
  • 2021-07-04
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案