0
I’m developing a web application using spring boot. I already have saved image of the user in the database, now I would like to assign the image of the user logged in 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.
My controller:
@Controller
public class IndexController {
@Autowired
private UsuarioService service;
@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>
See if the answers in this question help you.
– StatelessDev
@Statelessdev not necessarily, that’s why I already do there in detail, the question is, I have to take the image of the user in the session, because if it is according to the answer you sent I would have to do it for all controllers, if it would not return null object.
– Carlos Diego