把response.setContentType("text/html; charset=gb2312");
改为response.setContentType("application/doc;charset=GB2312");试试

解决方案 »

  1.   

    用的是sql server数据库
    上传代码是
    mySmartUpload.initialize(pageContext);
    mySmartUpload.upload();
    for(int i=0;i<mySmartUpload.getFiles().getCount();i++)
    {
    M_upload m =new M_upload();
    int max;
    if(fileID.equals("0"))
    max=m.getMaxID();
    else 
    max=Integer.parseInt(fileID);
    idChain=""+max;
    System.out.println(idChain);
    connFactory factory=new connFactory();
        DBConnect dbconn = factory.createConnect();
        conn = dbconn.setconnect();
    Statement stmt = conn.createStatement(ResultSet.TYPE_FORWARD_ONLY ,ResultSet.CONCUR_UPDATABLE);
    ResultSet rs = stmt.executeQuery("SELECT * FROM TFILES WHERE fileid="+max);

    if (rs.next())
    {
    if (!mySmartUpload.getFiles().getFile(i).isMissing())
    {
            try 
    {
            rs.updateString("FILENAME",mySmartUpload.getFiles().getFile(i).getFileName());
    mySmartUpload.getFiles().getFile(i).fileToField(rs,"FILE");
    rs.updateRow();
    count++;
    }
    catch(Exception e) 
    {
    System.out.println("An error occurs : " + e.toString());
    }
    }
    }
    rs.close();
    stmt.close();
    }
    conn.close();