开发者

Display image in Spring MVC

开发者 https://www.devze.com 2023-03-06 19:10 出处:网络
What is the proper way , using MultiActionController? I got in my Restaurant class: private byte[] logo;

What is the proper way , using MultiActionController? I got in my Restaurant class:

private byte[] logo;

In my database I got table BLOB image. By using hibernate, it saves to my database properly by:

<tr>
<td>Logo :</td>
<td>< inpu开发者_运维技巧t type="file" name="logo" /></td>
</tr>

But i dont know how to shows this image on another site. Maybe:

< img src="<%=("restaurant.logo")%>" alt="Upload Image" />

?


You should do something like this, create a new field in your Restaurant and have the byte[] converted to Image and use that field.


If I understand your problem, you need a controller getting your picture from database and returning it as a stream to web browser.

You can for example map controller method with request: /restaurant/logo/{id}

Then you should just type

<img src="<c:url value='/restaurant/logo/${restaurant.id}' />" alt="Upload Image" />

I you add more of code, I'll be able to give you more hints.


Please do have a look here!

This is more generic and points at all types of files upload and download.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号