重新写下jsp页面:
<%@ page contentType="application/msword; charset=gb2312" language="java" errorPage="" %>
<html><head>
<meta http-equiv="Content-Type" content="application/msword; charset=gb2312">
<title>无标题文档</title>
</head>
<body>
<%
response.reset();
response.setContentType("application/msword");
response.setHeader("Content-disposition","inline; filename=temp.doc");
byte[] word=(byte[])request.getAttribute("scanlist");
javax.servlet.ServletOutputStream os = response.getOutputStream();
os.write(word);
os.close();
%>
</body>
</html>

解决方案 »

  1.   

    <%@ page contentType="application/msword; charset=gb2312" language="java" errorPage="" %>
    <html><head>
    <meta http-equiv="Content-Type" content="application/msword; charset=gb2312">
    <title>无标题文档</title>
    </head>
    <body>
    <%
    response.setContentType("application/msword");
    //response.setHeader("Content-disposition","inline; filename=temp.doc");
    String s= "MIJ";
    byte[] word=s.getBytes();
    javax.servlet.ServletOutputStream os = response.getOutputStream();
    os.write(word);
    os.close();
    %>
    </body>
    </html>
      

  2.   

    我也做过这样的网页,好像ocean617(海洋) 应该是正确的
      

  3.   

    <%@ page contentType="text/html; charset=GBK" errorPage="" %>
    <html>
    <head>
    <title>无标题文档</title>
    </head>
    <body>
    <%
    response.setContentType("application/msword");
    response.setHeader("Content-disposition","inline; filename=temp.doc");
    String s= "MIJ";
    byte[] word=s.getBytes();
    javax.servlet.ServletOutputStream os = response.getOutputStream();
    os.write(word);
    os.close();
    %>
    </body>
    </html>
      

  4.   

    不错,基本和导出Excel差不多。
      

  5.   

    to: ocean617(海洋)
    其实是这样的,我只要在页面里一调用
    javax.servlet.ServletOutputStream os = response.getOutputStream();
    就会出错。我也试过这样的写法:
    <%@ page contentType="application/msword; charset=gb2312" language="java" errorPage="" %>
    <html><head>
    <meta http-equiv="Content-Type" content="application/msword; charset=gb2312">
    <title>无标题文档</title>
    </head>
    <body>
    <%
    response.setContentType("application/msword");
    response.setHeader("Content-disposition","inline; filename=temp.doc");
    javax.servlet.ServletOutputStream os = response.getOutputStream();
    %>
    </body>
    </html>
    也是报相同的错,望ocean617(海洋)解答。谢谢。
      

  6.   

    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.htt.*;
    public class extends HttpServlet
    {
    public void doGet(HttpServletRequest request,HttpServletResponse response)throws IOException ,ServletException
    {
    response.setContentType("application/ms-word;charset=gb2312");
    PrintWriter out=response.getWriter();
    out.print("ladj dlf  asd f df ");
    }
    }
      

  7.   

    first last email
    second last add
    <%@ page contentType="application/msword;charset=gb2312"%>
    这样也可以
      

  8.   

    import javax.servlet.htt.*;
    ........速度快了点‘
    因该是import javax.servlet.http.*;
      

  9.   

    楼上的兄弟
    输出word应该用流吧,response.getWriter()是输出文本.