在线预览PDF

来源:互联网 发布:淘宝卖家如何加入一淘 编辑:程序博客网 时间:2024/06/05 08:09

1.初步代码:

<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>

<script type="text/javascript">
 
    var openPdf = function (){
        window.open("<%=basePath %>/images/text.pdf");
        return false; 
      };
</script>

<button onclick="openPdf()">预览PDF</button>

也就是让浏览器自动打开PDF,但是IE不支持打开PDF;

2.测试文件时,遇到路径问题,发现是系统过滤了

spring-servlet.xml配置文件

0 0
原创粉丝点击