springmvc 文件下载

@RequestMapping("/download.htm")    app

    public ResponseEntity<byte[]> download(HttpServletRequest request, @RequestParam("fileId") String fileId) throws IOException {    spa

        String path="E:\\Users\\xc\\workspace\\ldassetWeb\\WebRoot\\js\\time.js";  orm

        File file=new File(path);  htm

        HttpHeaders headers = new HttpHeaders();    get

        String fileName=new String("文件.js".getBytes("UTF-8"),"iso-8859-1");it

        headers.setContentDispositionFormData("attachment", fileName);   io

        headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);   file

        return new ResponseEntity<byte[]>(FileUtils.readFileToByteArray(file), headers, HttpStatus.CREATED);    request

    } 下载



<a href="${ctx}/system/download.htm?fileId=188">下载</a>

相关文章
相关标签/搜索