我在servlet中生成一个图像:
ImageIO.write(bufferedImage,"jpg" ,Outputstream)
但是在部署之后我收到一条错误,它无法读取输入文件。
答案 0 :(得分:0)
很久以前我编写了以下代码(它将图像存储为数据库中的blob并将其写入servler输出):
public class ImageDB extends HttpServlet {
// ...
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// ...
byte[] bytes = blob.getBytes((long)1, (int)blob.length());
ServletOutputStream out = response.getOutputStream();
out.write(bytes);
out.close(); // Close stream
// ...
}
}