我现在已经把excel和word为格式的两个文件的路径已确认,怎么才能在jsp页面中分别显示word 和excel  应该怎么做。 谢谢了

解决方案 »

  1.   

    设置页面的mime类型就可以网上很多
      

  2.   

    我也找了。。  就是不知道jsp界面是怎么找到文件路径的。 并显示出来的。。 望给予答案。。 谢谢饿
      

  3.   

    1在web.xml中加入:   
          <mime-mapping>   
              <extension>ppt</extension>   
              <mime-type>application/mspowerpoint</mime-type>   
          </mime-mapping>   
    2在jsp页头引入
    <%@page contentType="application/msword;charset=gbk"%>
    这是在浏览器中已word形式打开
    <%@page contentType="application/vnd.ms-excel;charset=gbk"%>
    这是以excel
      

  4.   

    ....是不是和mime相关的,不清楚
      

  5.   

    我想问一下  jsp是怎么找到路径显示excel和word的
      

  6.   

    我想问一下  jsp是怎么找到路径显示excel和word的
      

  7.   

    你在JSP里  加
    <%
    response.setContextType("application/vnd.ms-excel");%>
     看行不?
      

  8.   

    直接用个servlet,然后得到文件流,用servletOutputStream输出,输出之前,setContentType("")对应word或者excel的mime类型,

    FileInputStream is=new FileInputStream(new File("文件路径"));
    response.setContentType("正确的mime类型");byte[] b=new byte[is.available()];
    is.read(b);
    response.getOutputStream().write(b);
    这样就输出了     
      

  9.   

    链接的路径会写吧。
    <a href="./word.doc">open the word</a>
    在web.xml里面加上下面两句:
        <mime-mapping>
            <extension>doc</extension>
            <mime-type>application/vnd.ms-word</mime-type>
        </mime-mapping>
        
        <mime-mapping>
            <extension>xls</extension>
            <mime-type>application/vnd.ms-excel</mime-type>
    </mime-mapping>
      

  10.   


    <%
        response.setContentType("application/vnd.ms-excel");
        String xlsFile = this.getClass().getClassLoader().getResource("/").getPath() + "/../../view.xls"; 
        OutputStream output = null; 
        FileInputStream fis = null; 
        try 
        { 
            output  = response.getOutputStream(); 
            fis = new FileInputStream(filenamedownload); 
    byte[] b = new byte[1024]; 
    int i = 0; 
    while((i = fis.read(b)) > 0) 

    output.write(b, 0, i); 

    output.flush(); 

    catch(Exception e) 

    System.out.println(\"Error!\"); 
    e.printStackTrace(); 

    finally 

    if(fis != null) 

    fis.close(); 
    fis = null; 

    if(output != null) 

    output.close(); 
    output = null; 

    }
    %>