如何在  jsp页面上显示 pdf内容  请高手指教一下要求是在 jsp页面上弹出一个window  来显示

解决方案 »

  1.   


    <object classid="clsid:CA8A9780-280D-11CF-A24D-444553540000" width="100%" height="500" border="0">
      <param name="_Version" value="65539">
      <param name="_ExtentX" value="20108">
      <param name="_ExtentY" value="10866">
      <param name="_StockProps" value="0">
      <param name="SRC" value="@file://d:/1.pdf">
      </object>弹出一个Windows?
    这个不知,一定要触发才行吧
      

  2.   

    jsp代码中加入  如下即可
    response.setHeader("Content-Type","application/pdf");
    response.setHeader("Content-Disposition","attachment;filename=asd.pdf");第一行通知浏览器,接受的内容是pdf格式
    第二行通知浏览器,接受的文件名字是asd.pdf
      

  3.   

    <a href="asd.pdf" target="_blank">view pdf file in another tab</a>
      

  4.   

    这个问题我找到答案了………………但是中文问题还没解决    就是目录 文件名是中文的话 就会出错http://topic.csdn.net/u/20100911/15/2733d498-ac89-4f9e-a85e-8215ba255aaa.html
      

  5.   

    在SERVLET中显示PDF内容,直接在浏览器中输入SERVLET访问路径即可显示
    public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
            //可在tomacat/conf/web.xml中查看各种文件的显示格式:pdf为application/pdf,ppt为application/powerpoint
    response.setContentType("application/pdf;charset='gb2312'");
    FileInputStream fis=new FileInputStream("d:\\struts入门(中文版).pdf");
    ServletOutputStream sos=response.getOutputStream();
    byte[] buffer=new byte[1024];
    int i=0;
    while((i=fis.read(buffer))!=-1){
    sos.write(buffer, 0, buffer.length);
    }
    sos.flush();
    sos.close();
    }
      

  6.   

    的确 pdf文件是可以直接用io流在 页面上直接显示出来
    但是 office 系列的就不行了