有个word文档以Blob的方式存在数据库中,现在在前台要下载这个word文档。
从JSP页面中用objHttp的方式传值到java中,Java根据前台传入的参数定位读取这个blob字段,跟踪过程序了,java在循环解析的过程中没有出错异常,但最后弹出alert框,内容如下:文本内容中发现无效字符。
0
求解,谢谢!

解决方案 »

  1.   

    抱歉,代码贴不出来。
    就是预先将一个word文档写入数据库中的Blob字段,现在在JAVA中要解析这个字段,然后把word文档下载下来。结果出现了如题所示的异常。
      

  2.   

    你既然保存word文档就可以将文档另存啊,要下载,直接给个访问地址就行了!
      

  3.   

    public class CopyOfCURD_byte_select {
    static Connection con;
    static Statement st;
    static ResultSet rs;
    public static void main(String[] args) {
    try {
    con = JDBC.getConnection();
    String sql = "select big_int from blob_test";
    st = con.createStatement();
    rs = st.executeQuery(sql);
    while(rs.next())
    {
    InputStream in = rs.getBinaryStream(1);
    File f = new File("c:\\a.doc");
    OutputStream out = new BufferedOutputStream(new FileOutputStream(f));
    byte[] b = new byte[1024];
    for(int i = 0; (i = in.read(b)) > 0 ;)
    {
    out.write(b,0,i);
    }
    out.close();
    in.close();
    }
    } catch (FileNotFoundException e) {
    e.printStackTrace();
    } catch (SQLException e) {
    e.printStackTrace();
    } catch (IOException e) {
    e.printStackTrace();
    } catch (Exception e) {
    e.printStackTrace();
    } finally {
    try {
    //关闭文件和连接
    } catch (Exception e) {
    e.printStackTrace();
    }
    } }
    }
      

  4.   


    这不是将文档另存为的问题。
    6楼的朋友这段代码和我的处理是一样的。但如果是用AJAX在JSP页面触发调用这段程序的话,可能就有问题了。用form表单的方式触发是可以的。