tomcat 中怎么支持doc文件?高价悬赏!!! 具体什么意思,是否想在netscape看doc文件。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 是呀!我用<mime-mapping> <extension> doc </extension> <mime-type> application/msword </mime-type> </mime-mapping>不行web.xml 啊,这样行吗!?看看apache Cocoon. 是不是在XML里存着DOC的数据,在好象上面指定数据的类型,让netscape看。 http://xml.apache.org/cocoon/install.html#tomcat 不是呀,是直接关联的例如:http://www.test.com/ccc.doc 是不是XML里指着DOC 文件的路径,在好象上面指定数据的类型,让netscape显示。 不是XML里指着DOC 文件的路径,是在jsp里指定的。怎么办呀? 在JSP里读取DOC的文件流输出到response.getOutputStream()里不就可以吗。 response.getOutputStream()能对中文起作用吗,现在是乱码呀!? 问题是希望看到word形式的页面。而不是乱吗,或乱排的页面。 我写了一个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); } }} 奥!!!!!!!!!!!!!!!原来我的netscape没装word97插件.搞死我了!!!!!!1!!!! JSP有关,解释下几个属性 dreamweaver中按钮设置成超链接? 问个doGet与doPost的老问题 求助:ResultSet对象中的数据导到ArrayList[]中,总出错!~ 请问我生成的.shtml文件,在英文操作系统上怎么是乱码,解决后给分100 jsp和数据库相连出问题 怎么编译不了? 请问 创建菜单树问题 jsp+tomcat的问题: 欢迎继续讨论,jsp工作原理?进者有分,我全给了 请问我为什么找不到javax.Servlet 在使用jsp与servlet结合使用时,编写的servlet的java程序,一定要通过编译生成.class文件才能使用,是吗?
<mime-mapping>
<extension>
doc
</extension>
<mime-type>
application/msword
</mime-type>
</mime-mapping>
不行
web.xml
看看apache Cocoon.
例如:http://www.test.com/ccc.doc
怎么办呀?
能对中文起作用吗,现在是乱码呀!?
乱排的页面。
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);
}
}
}
原来我的netscape没装word97插件.
搞死我了!!!!!!1
!!!!