如何在jsp页面直接打开word文件,而不提示下载信息啊
我的网站后台新闻编辑用的是fckeditor,在编辑新闻的时候,如果在一串文字上添加了个超级连接,当用户浏览新闻的时候,点击该连接,如何能直接打开word文件,而不提示用户下载,怎样实现这样的功能啊?
我的网站后台新闻编辑用的是fckeditor,在编辑新闻的时候,如果在一串文字上添加了个超级连接,当用户浏览新闻的时候,点击该连接,如何能直接打开word文件,而不提示用户下载,怎样实现这样的功能啊?
解决方案 »
- 求解 EXTJS 3.0 这个错误:Uncaught TypeError: Cannot set property 'width' of undefined
- 严重: Servlet.service() for servlet jsp threw exception
- jsp或jsf中怎么插入flash页 然后跳转至其它页面
- struts2标签问题
- 编译不能通过
- ajax 数据的显示与隐藏问题
- 求助各位大哥哥,我有个棘手的问题
- 请教二个用servlet做jsp网页的问题,谢谢!(我是菜鸟,请别见笑)
- 我是个java初学者, 这个问题很难吗?不知道 severlet 有 将页面上的标记库, 实例化为Action 端对应标记库对象的技术呢?
- response.setContentType("???")怎样才能支持所有的文件类型
- 动态上传附件 IE与firefox的兼容
- <html:link>发送参数后,取值的问题?
还是直接打开?
直接打开的话可以运用dos命名撒!
<center>
<iframe name="resource" src="" width="100%" scrolling="auto" frameborder="0"></iframe>
</center>打开,src是你word的连接地址。
response.setContentType("application/x-msword");
response.addHeader("Content-Disposition","attachment;filename=" + "C:\\x.doc");
response.reset();
response.setContentType("application/x-msword");
response.addHeader("Content-Disposition","attachment;filename=" + "C:\\x.doc");
那么在上面这段程序里"filename=" + "C:\\x.doc"语句怎样才能动态实现这个功能呢,谢谢!
response.addHeader("Content-Disposition","attachment;filename=" + path);
path是word文件的路径
response.setContentType("application/msword;charset=gb2312");
response.setHeader("Content-Disposition","inline;filename=\""+filename+"\"");
希望以上能够帮到求助者。
<HTML>
<HEAD>
<TITLE>open word/execl</TITLE>
</HEAD>
<BODY>
<a href="./word.doc">open the word</a>
</BODY>
</HTML>
在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>
试试吧,应该是没问题的。
response.reset();
response.setContentType("application/x-msword");
response.addHeader("Content-Disposition","attachment;filename=" + "C:\\x.doc");
那么在上面这段程序里"filename=" + "C:\\x.doc"语句怎样才能动态实现这个功能呢,谢谢! response.addHeader("Content-Disposition","attachment;filename=" + "C:\\x.doc");
可以改用输出流
ServletOutputStream sos = response.getOutputStream();
然后把你的内容写入输出流
BufferedOutputStream bos = new BufferedOutputStream(sos);
<td height="72" colspan="2"><a href="path"><img srcpath" alt="" name="load" border="0"></a></td>
</tr>我做过这样的。这样写可直接打开