jsp中文档文件下载
发布日期:2021-05-08 09:44:57 浏览次数:23 分类:精选文章

本文共 913 字,大约阅读时间需要 3 分钟。

        文件下载    <%        String path = request.getContextPath();        String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";    %>    <%        String para = request.getParameter("a");        response.setContentType("application/x-download");        String filePath = "/" + para;        String displayName = para;        displayName = URLEncoder.encode(displayName, "UTF-8");        response.addHeader("Content-Disposition", "attachment;filename=" + displayName);    %>    <%        try {            RequestDispatcher dis = application.getRequestDispatcher(filePath);            if (dis != null) {                dis.forward(request, response);            }            response.flushBuffer();        } catch (Exception e) {            e.printStackTrace();        } finally {            out.clear();            out = pageContext.pushBody();        }    %>
上一篇:Hibernate操作Blob,将Blob转换为String
下一篇:json串操作

发表评论

最新留言

不错!
[***.144.177.141]2025年04月13日 17时02分17秒