I have got table and display datas from database (mysql). I use thymeleaf. All fields are ok but sb.cover doesnt show jpg (blob column in my database). Have you got any ideas how to put jpg in web page using thymeleaf? Thanks
<tr th:each="sb, poz : ${product}">
<td th:text="${poz.count}">1</td>
<td th:icon="${sb.cover}"></td>
<td th:text="${sb.title}"></td>
<td th:text="${sb.price}"></td>
<td ><b><a th:href="@{/details}">DETAILS</a></b></td>
<td ><b><a th:href="@{/cart}">ADD TO CART</a></b></td>
</tr>
It's worked for me:
<img class="info" th:attr="src=@{${image}}" />
where 'image' is base64 image:
image = "data:image/png;base64,R0lGODlhlgCWAMQAAPz.........
in Spring Java Controller:
@RequestMapping(value = "/get_goods_detail", method = RequestMethod.GET)
public String getGoodsDetail(@RequestParam(value = "itemid") final int itemid,
ModelMap model) {
// get image
String image = "data:image/png;base64,R0lGODlhlgCWAMQAAPz8/N3d3eX.../big image
model.addAttribute("image", image);
return "goods_detail"; // return name of html view with thymeleaf
}
I am not sure this will help you...
<tr th:each="sb, poz : ${product}">
<td th:text="${poz.count}">1</td>
<td><img th:attr="src=@{${sb.cover}} , title=#{background}, alt=#{background}" style="width: 150px; height: 150px;" /></td>
<td th:text="${sb.title}"></td>
<td th:text="${sb.price}"></td>
<td ><b><a th:href="@{/details}">DETAILS</a></b></td>
<td ><b><a th:href="@{/cart}">ADD TO CART</a></b></td>
</tr>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With