我要用jsp直接打开word,而不是在保存/打开的对话框中选择打开!代码如下:
<%@page import="java.util.*"%>
<%@page import="java.io.*"%>
<%@page import="java.net.*"%>
<html>
<head>
<title>
qq
</title>
</head>
<body bgcolor="#ffffff">
<%
response.setContentType("application/ms-word");
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
try {
bis = new BufferedInputStream(new FileInputStream("D:\\myjava\\iptest\\WebModule1\\aaa.doc"));
bos = new BufferedOutputStream(response.getOutputStream());
byte[] buff = new byte[2048];
int bytesRead;
while ( -1 != (bytesRead = bis.read(buff, 0, buff.length))) {
bos.write(buff, 0, bytesRead);
}
}
catch (final IOException e) {
System.out.println("出现IOException." + e);
}
finally {
if (bis != null)
bis.close();
if (bos != null)
bos.close();
}
%>
</body>
</html>
<p>
|
不好意思,程序没出来!
但是仍然弹出保存/打开对话,折腾了半天还是搞不定!
请大家帮忙。谢谢!