我想讀取來自數據庫的blob類型的圖像。我在控制器中的方法。只有圖像文件在JSP上顯示沒有其他東西blob圖像渲染在春天mvc 3.0
@RequestMapping(value = "/showDetails")
public ModelAndView showDetails(@RequestParam("doc") int id,
HttpServletResponse responce) {
ModelAndView mView = new ModelAndView();
File file = documentDao.getFileDetail(id);
byte[] bytes = null;
try {
OutputStream op = responce.getOutputStream();
int length = (int) file.getContent().length();
bytes = file.getContent().getBytes(1, length);
op.write(bytes);
op.flush();
op.close();
responce.setContentType("image/gif");
mView.addObject("image", op);
} catch (Exception e1) {
e1.printStackTrace();
}
mView.addObject("file", file);
mView.setViewName("filedetails");
return mView;
}
上述方法在我的控制器類中。我想在JSP上渲染圖像以及一些文本。但只有圖像來自瀏覽器。
我無法格式化此代碼。抱歉在閱讀/理解代碼時遇到問題。 – user1779379
你還想顯示其他圖像嗎? – shazinltc
我想顯示一些文字。 filedetails.jsp - >
----
–
user1779379