0

以下 servlet 代码从数据库表中获取图像字节。

protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    Configuration config = new Configuration().configure();
    SessionFactory sessFact = config.buildSessionFactory();
    Session sess = sessFact.openSession();
    pojo.File image_file = (pojo.File)sess.get(pojo.File.class, 2);
    byte image_file_bytes[] = image_file.getFiles_uploaded(); 

    // NOW WHAT ? HOW DO I MAKE IT DISPLAY IN THE BROWSER ?
}

我有bytes. 接下来我该怎么做才能在浏览器上显示图像?

4

1 回答 1

1

您使用 HttpServletResponse 的 OutputStream 来写出数据。

于 2013-06-07T07:30:34.217 回答