web 项目中的 <a href="c:\a.xls">dd</a> 如何用excel打开? 在web 项目中,jsp 文件中用 <a href="c:\a.xls">dd</a> ,关联了一个 excel 文件,当点击时,会弹出 打开 保存 的对话框 , 保存没有问题, 可是打开时总是在 ie 中打开,我想点打开时,用 Excel 打开,怎么设置或是怎么做呀? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 试试<a href="c:\a.xls" target="_blank">dd </a> 试一下下面的方法看行不行,没测试:<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> 试试 <a href="c:\a.xls" target="_blank">dd </a>这种方法,它会重新打开一个新的 ie 窗口,但 xls 文件还是在ie中打开的,行不通,谢谢! zhoupuyue 老兄的在web.xml 中的设置,我也试过了,也不行,我用的ie7 你是不是把windows的xls类型文件和IE关联了? 用的是JSP 那Jsp 本身 表头标签 有EXCEL 的标签具体标签忘了没记你找下把 操作也是正常 把数据传给JSP 在JSP 你写入那个表头标签 然后数据有拼表格就行 获取数据 sun914 : 您好!我没太明白你的意思,可以详细解说一下吗? 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> 通过URL传递JSON格式参数的问题 spring 3急啊~~~ 关于单例模式在spring和struts中的应用 mysql,启动报错,强烈纠结中 struts2.xml配置问题 关于在java虚拟主机中支持javax.script库的问题 高手们,学IceFaces有什么好书可以参考!!! 帮忙阿~~~ 问有关ResultSet的问题. 同志们,有没有关于java和jsp的新闻组,给几个地址吧。大恩不敢言谢!:-) struts 2在weblogic下运行奇怪问题?网上搜索无结果 请高手指点......
<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>
您好!我没太明白你的意思,可以详细解说一下吗?
<%
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>