tomcat 中怎么支持doc文件?高价悬赏!!!

flywow 2001-05-08 03:41:00
tomcat 中怎么支持doc文件,在netscape中呀!!!
...全文
139 17 打赏 收藏 转发到动态 举报
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
skyyoung 2001-05-09
  • 打赏
  • 举报
回复
哈哈
flywow 2001-05-09
  • 打赏
  • 举报
回复
奥!!!!!!!!!!!!!!!
原来我的netscape没装word97插件.
搞死我了!!!!!!1
!!!!
flywow 2001-05-09
  • 打赏
  • 举报
回复
我写了一个servlet,但是他提示下载*.doc文件,而不是显示word文档。

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;


public class FileView extends HttpServlet
{

private ServletConfig config = null;
private String xFilePath = null;
private String strDefaultDir = null;
private String separator = null;

public FileView()
{

separator = System.getProperty("file.separator");
}

public final void init(ServletConfig servletconfig)
throws ServletException
{
config = servletconfig;
}

public final ServletConfig getServletConfig()
{
return config;
}

public void doGet(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse)
throws ServletException, IOException
{
doPost(httpservletrequest, httpservletresponse);
}

public void doPost(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse)
throws ServletException, IOException
{

String s1 = httpservletrequest.getParameter("name");
String s = httpservletrequest.getParameter("path");

GetFile(s, s1, httpservletresponse);

}

private void GetFile(String s, String s1, HttpServletResponse httpservletresponse)
throws IOException
{
httpservletresponse.setContentType("application/msword; name=" + s1 + "\"");
httpservletresponse.setHeader("Content-Disposition", "inline;filename=" + s1 + "\"");
javax.servlet.ServletOutputStream servletoutputstream = httpservletresponse.getOutputStream();
dumpFile(s, servletoutputstream);
servletoutputstream.flush();
servletoutputstream.close();
}

private void dumpFile(String s, OutputStream outputstream)
{
byte abyte0[] = new byte[4096];
try
{
FileInputStream fileinputstream = new FileInputStream(s);
int i;
while((i = fileinputstream.read(abyte0)) != -1)
outputstream.write(abyte0, 0, i);

fileinputstream.close();
}
catch(Exception exception)
{
System.out.println(exception);
}
}
}
muqiao 2001-05-09
  • 打赏
  • 举报
回复
好像还要装world 97吧
skyyoung 2001-05-08
  • 打赏
  • 举报
回复
没有问题啊。
flywow 2001-05-08
  • 打赏
  • 举报
回复
问题是希望看到word形式的页面。而不是乱吗,或
乱排的页面。
flywow 2001-05-08
  • 打赏
  • 举报
回复
response.getOutputStream()
能对中文起作用吗,现在是乱码呀!?
skyyoung 2001-05-08
  • 打赏
  • 举报
回复
在JSP里读取DOC的文件流输出到response.getOutputStream()里不就可以吗。
flywow 2001-05-08
  • 打赏
  • 举报
回复
不是XML里指着DOC 文件的路径,是在jsp里指定的。
怎么办呀?
skyyoung 2001-05-08
  • 打赏
  • 举报
回复
是不是XML里指着DOC 文件的路径,在好象上面指定数据的类型,让netscape显示。
flywow 2001-05-08
  • 打赏
  • 举报
回复
不是呀,是直接关联的
例如:http://www.test.com/ccc.doc
skyyoung 2001-05-08
  • 打赏
  • 举报
回复
http://xml.apache.org/cocoon/install.html#tomcat
skyyoung 2001-05-08
  • 打赏
  • 举报
回复
是不是在XML里存着DOC的数据,在好象上面指定数据的类型,让netscape看。
flywow 2001-05-08
  • 打赏
  • 举报
回复
在那看呀?
skyyoung 2001-05-08
  • 打赏
  • 举报
回复
啊,这样行吗!?
看看apache Cocoon.
flywow 2001-05-08
  • 打赏
  • 举报
回复
是呀!我用
<mime-mapping>
<extension>
doc
</extension>
<mime-type>
application/msword
</mime-type>
</mime-mapping>
不行
web.xml
skyyoung 2001-05-08
  • 打赏
  • 举报
回复
具体什么意思,是否想在netscape看doc文件。

81,092

社区成员

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

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