I 'm a beginer with spring framework. I insert an image to postgresql database and i want to display it. the model class is:
@Data
@Entity
@Table(name="Item")
public class Item {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer id;
private String name;
private byte[] imageTo_display;
private Long price;
@ManyToOne
private Cart cart;
}
I think the problem is at image tag but i don't know how to solve it . and the html is:
<th:block th:each="item:${listItems}">
<tr>
<td>[[${item.id}]]</td>
<td>[[${item.name}]]</td>
<td>[[${item.price}]]</td>
<td> <img class="s-ava-alone-img" width="150" height="150" th:src="@{${item.imageTo_display}}"></td>
</tr>
<td>
<a class="h4 mr-3" th:href="@{'/users/edit/'+${item.id}}">Edit</a>
<a class="h4 mr-3" th:href="@{'/users/delete/' +${item.id}}">Delete</a>
</td>
</th:block>