请问,怎么样才能把word嵌入到浏览器中,谢谢

tr100 2002-07-06 09:42:07
请问,怎么样才能把word嵌入到浏览器中
谢谢,请给出示例
...全文
68 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
wyy_9715072 2002-07-07
  • 打赏
  • 举报
回复
如果你的servlet的URL是http://serverUrl/servlet/servletname
则用户输入http://serverUrl/servlet/servletname,他会自动调用本地的word
打开你传出的流
就像我给的例子,你可以补充fileContext的内容后就可以通过,比如打开一个服务器的word文件,将其读成字符流,然后,把servlet部署到服务器上就可以
theMost 2002-07-07
  • 打赏
  • 举报
回复
请问如何运用
可以给出一个示例么?
wyy_9715072 2002-07-06
  • 打赏
  • 举报
回复
是指用word打开文档是吗,你可以向客户端输出一个流,流的属性为用word打开就可以了,不过,好像得用servlet,可能jsp也可以,我没有试过,
不过,可以给你servlet的代码
import java.io.*;

public class GetFile extends HttpServlet
{
public void doGet (HttpServletRequest req,HttpServletResponse res)
throws ServletException,IOException
{
try
{
byte[] fileContext=为你要输出的word的字符流
res.setContentType("application/msword");
ServletOutputStream servletOut = res.getOutputStream();
res.setContentLength(fileContext.length);
servletOut.write(fileContext);
servletOut.close();
}
}
catch(Exception e)
{
throw new ServletException(e);
}
}
}

81,091

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧