zax
zax

Reputation: 147

Display image in Spring MVC

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>< input 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" />

?

Upvotes: 1

Views: 5163

Answers (3)

Achow
Achow

Reputation: 8678

Please do have a look here!

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

Upvotes: 0

Patryk Dobrowolski
Patryk Dobrowolski

Reputation: 1595

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.

Upvotes: 0

abalogh
abalogh

Reputation: 8281

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

Upvotes: 1

Related Questions