I'm developing a web application using spring boot. I already have a saved image of the user in the database, now I would like to assign the image of the user logged into the session in the profile photo of my dashboard. How to do this? I can bring other information like name and cnpf, but his image can not.
Mycontroller:
@ControllerpublicclassIndexController{@AutowiredprivateUsuarioServiceservice;@RequestMapping("/index")
public ModelAndView index(HttpSession session) {
Usuario usuario = service.findByEmail(SecurityContextHolder.getContext().getAuthentication().getName());
ModelAndView mv = new ModelAndView("/home");
session.setAttribute("usuario", usuario);
return mv;
}
My html page:
<div class="avatar">
<img th:src="@{/session.usuario/image/{image_id}(image_id=${session.usuario.id})}">
</div>
<div class="title">
<h1 class="h6" th:text="${session.usuario.nome}"></h1>
<p class="h2" th:text="${session.usuario.cnpjCpf}"></p>
</div>
</div>