h**d 发帖数: 474 | 1 I have some images saved in db using BLOB.
I need to display one image with other information using struts2 framework,
now my action has the byte array of image.
What's the easiest solution? What's the most elegant solution?
What I can think about: save it as a temp file, and show it as a link in JSP.
Thanks.... | o***g 发帖数: 2784 | 2 没做过
应该可以写个servlet处理*.a请求,发送图片数据
JSP.
【在 h**d 的大作中提到】![](/moin_static193/solenoid/img/up.png) : I have some images saved in db using BLOB. : I need to display one image with other information using struts2 framework, : now my action has the byte array of image. : What's the easiest solution? What's the most elegant solution? : What I can think about: save it as a temp file, and show it as a link in JSP. : Thanks....
| g*****g 发帖数: 34805 | 3 From browser point of view, your image is nothing more than
a link, it has to be a known extension though otherwise some browser
may not be able to render it as image.
For Spring MVC, you can map all links to some folder,
etc. /img/* to some controller, then you can write the
image back, all you need to do is set appropriate image
mime type. Sth. like
httpServletResponse.setContentType(image.getMimeType());
httpServletResponse.setContentLength(image.getLength());
httpServletResponse.getOutputStr
【在 h**d 的大作中提到】![](/moin_static193/solenoid/img/up.png) : I have some images saved in db using BLOB. : I need to display one image with other information using struts2 framework, : now my action has the byte array of image. : What's the easiest solution? What's the most elegant solution? : What I can think about: save it as a temp file, and show it as a link in JSP. : Thanks....
| h**d 发帖数: 474 | 4 thanks, will give a try...
It seems that I have to write the image into the temp file first:(
I'm using struts2, which is actually webwork:)
【在 g*****g 的大作中提到】![](/moin_static193/solenoid/img/up.png) : From browser point of view, your image is nothing more than : a link, it has to be a known extension though otherwise some browser : may not be able to render it as image. : For Spring MVC, you can map all links to some folder, : etc. /img/* to some controller, then you can write the : image back, all you need to do is set appropriate image : mime type. Sth. like : httpServletResponse.setContentType(image.getMimeType()); : httpServletResponse.setContentLength(image.getLength()); : httpServletResponse.getOutputStr
| m**c 发帖数: 192 | 5 goodbug说的这个方法不需要temp file吧
最好不要用temp file
【在 h**d 的大作中提到】![](/moin_static193/solenoid/img/up.png) : thanks, will give a try... : It seems that I have to write the image into the temp file first:( : I'm using struts2, which is actually webwork:)
| g*****g 发帖数: 34805 | 6 You don't, but on the other hand, if there's no security issue,
I'd seriously consider caching images in appserver. And only goto
DB if image cannot be found in cache.
【在 m**c 的大作中提到】![](/moin_static193/solenoid/img/up.png) : goodbug说的这个方法不需要temp file吧 : 最好不要用temp file
| h**d 发帖数: 474 | 7 I have to display other information other than this image...:(
【在 g*****g 的大作中提到】![](/moin_static193/solenoid/img/up.png) : You don't, but on the other hand, if there's no security issue, : I'd seriously consider caching images in appserver. And only goto : DB if image cannot be found in cache.
|
|