在web 项目中,jsp 文件中用 <a href="c:\a.xls">dd</a>  ,关联了一个 excel 文件,当点击时,会弹出 打开  保存 的对话框 , 保存没有问题, 可是打开时总是在 ie 中打开,我想点打开时,用 Excel 打开,怎么设置或是怎么做呀?

解决方案 »

  1.   

    试试<a href="c:\a.xls" target="_blank">dd </a>
      

  2.   

    试一下下面的方法看行不行,没测试:<a   href=".../test1.doc">open   the   word</a>  
      <a   href=".../test2.xls">open   the   excel</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> 
      

  3.   

    试试 <a href="c:\a.xls" target="_blank">dd </a>这种方法,它会重新打开一个新的 ie 窗口,但 xls 文件还是在ie中打开的,行不通,谢谢!
      

  4.   

    zhoupuyue 老兄的在web.xml 中的设置,我也试过了,也不行,我用的ie7
      

  5.   

    你是不是把windows的xls类型文件和IE关联了?
      

  6.   

    用的是JSP   那Jsp 本身 表头标签 有EXCEL  的标签具体标签忘了没记你找下把   操作也是正常  把数据传给JSP  在JSP 你写入那个表头标签  然后数据有拼表格就行 获取数据 
      

  7.   

    sun914 :
     您好!我没太明白你的意思,可以详细解说一下吗?
      

  8.   

    openType.jsp<%@ page language="java" import="java.util.*" pageEncoding="gb2312"%>
    <%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
        <base href="<%=basePath%>">
        
        <title>My JSP 'openType.jsp' starting page</title>
        
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">    
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->  </head>
      
      <body>
        <% String str1=request.getParameter("submit1");
           String str2=request.getParameter("submit2");
           if(str1==null)
           {
             str1="";
           }
           if(str2==null)
           {
             str2="";
           }
           if(str1.startsWith("word"))
           {
             response.setContentType("application/msword");
           }
           if(str2.startsWith("excel"))
           {
             response.setContentType("application/x-msexcel");
           }
         %>
         <jsp:include page="A.txt" />
      </body>
    </html>
    setMine.jsp <%@ page language="java" import="java.util.*" pageEncoding="gb2312"%>
    <%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
        <base href="<%=basePath%>">
        
        <title>MIME类型</title>
        
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">    
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->  </head>
      
      <body>
        <p>你想使用什么方式查看文本文件A.txt?</p>
        <form action="openType.jsp" method="post" name=form>
          <input type="submit" name="submit1" value="word">
          <input type="submit" name="submit2" value="excel">
        </form>
      </body>
    </html>