系统是b/s结构,小弟需要在客户端web页面中直接打开服务器端的word文档(不能出现下载对话框),请问在jsp中该如何实现。现在的情况是点击该链接后就出现的下载对话框。
下面是jsp代码:
<%@ page contentType="text/html; charset=GBK"%>
<%@ include file="../../common/taglibs.jsp"%>
<%@ page import="com.sany.system.CoursewareManage"%>
<html> <head>
<base href="<%=basePath%>">
<title>课件列表</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="css/sany.css" type="text/css">
</head> <body bgcolor="#FFFFFF" text="#000000" background="images/bg01.gif"
leftmargin="0" topmargin="8">
<form name="courseForm" method="post" aciton="">
<table width="760" border="0" cellspacing="0" cellpadding="0"
align="center" class="border01" bgcolor="#FFFFFF">
<tr>
<td colspan="5">
<table width="100%" border="0" cellspacing="5" cellpadding="0">
<tr>
<td bgcolor="#CC0000">
&nbsp;
</td>
</tr>
</table>
</td>
</tr> <tr>
<td align="center" colspan="5">
<table width="100%" border="0" cellspacing="5" cellpadding="0">
<tr>
<td bgcolor="#CCCCCC" colspan="5">
<img src="images/space.gif" width="1" height="10">
</td>
</tr>
<tr>
<td colspan="5" valign="top" bgcolor="#efefef">
<img src="images/t_01.gif" width="752" height="34">
</td>
</tr>
<tr><td><a href="123.doc">clickme</a></td></tr>
</table>
</td>
</tr>
<tr>
<td align="center" colspan="5">
<table width="100%" border="0" cellspacing="5" cellpadding="0">
<tr>
<td bgcolor="#CCCCCC" colspan="5">
<img src="images/space.gif" width="1" height="10">
</td>
</tr>

<%

%>
</table>
</td>
</tr>
<tr>
<td bgcolor="#FFFFFF" colspan="5">
<img src="images/space.gif" width="1" height="2">
</td>
</tr>
</table>
</form>
</body>
</html>

解决方案 »

  1.   

    可以调用win自身的word打开就可以了吧!
      

  2.   

    contentType="text/html ,属性改一下,具体网上找找啊
      

  3.   

    response.setContentType("application/unknown");
    response.addHeader("Content-Disposition", "attachment; filename="+fileName);
    fileName下载的文件名
      

  4.   

    多谢各位兄弟的答复,不过这些方法都不能去除下载提示框:(有没有什么好的方法能让客户端打开word文档时不出现任何提示就直接在IE中打开?
      

  5.   

    其实我也碰到过类似问题
    但是下载对话框的下面不是有一个
    “打开此类文件总是询问”的checkbox吗?
    把前面的勾去掉
    下次就直接打开word文件了
    属于不是办法的办法~~~~
      

  6.   

    呵呵,直接window.location=“文件路径url”
      

  7.   

    装了OFFICE的机器
    直接用<a>都能直接打开的...
      

  8.   

    resp.setHeader("Content-Disposition","inline; filename=\"JabberClient.jnlp\"");
      

  9.   

    假设word文件在服务器 \upload\word\word.doc路径下
    path="\upload\word\word.doc";
    <a href="<%=path%>" >WORD</a>
      

  10.   

    用Response的重新定向功能,定位到我word文档所在的url路径
      

  11.   

    从安全角度上看,根本不可能绕过下载提示框,否则我服务端随便放一个木马程序,你都不提示就运行,那安全性何在?除非更改客户端安全级别,weky(weky)所说的其实就是变相的改变了客户端的安全级别,或者做一个控件,要对方下载,这样同样是需要更改安全级别,还不如像weky(weky)所说的提示以后直接钩掉。