0

次のサーブレット コードは、データベースのテーブルからイメージ バイトを取得します。

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 に答える