How could I display images from a list of collection, which retrieved images from mysql db and has contents of images in bytes.
@RequestMapping(value = "media-nenuid/{menuid}", method=RequestMethod.GET)
public String postmedia(Model model, @ModelAttribute Imagefile
newimgfile,@PathVariable int menuid ) {
Menu menu = menuDao.findOne(menuid);//this find the menu with id passed in.
List<Imagefile> imagefiles = menu.getImagefiles();//then imagefiles has
filenames, and images' content of that menuid.
model.addAttribute("imagefiles", menu.getImagefiles());//passing to thymeleaf.
return "Imagefile/media-menuid"; }
Syntax in thymeleaf.
<table class="table">
<tr th:each="image : ${imagefiles}">
<td><img th:src="@{${image.imagecontent}}"></img></td>
</tr>
</table>
Under Chrome inspect, image display error.
<tr>
<td>
<img src="[B@8f0d25">
</td>
/tr>