So, I'm doing an assignment where we have to use Spring Boot and Thymeleaf. I need to display the bio box of a user in the system, but it doesn't allow me. I can easily System.out.print the bio, but I can not make it show on my html page. Controller looks like this:
@GetMapping("/myProfile")
public String myProfile(HttpServletRequest request, Model model){
HttpSession session = request.getSession();
User user = (User) session.getAttribute("user");
model.addAttribute("userToDisplay", userToDisplay);
System.out.println("Printing from myProfile "+ user.getBio());
if(user!=null){
return "myProfile";
} else{
return "redirect:/";
}
}
And the relevant HTML part looks like:
<div class="textarea">
<form action="/infoPost" method="post" id="bioForm">
<textarea id="infoBox" name="bio" rows="10" cols="50" th:field="${userToDisplay.getBio()}" placeholder="Describe yourself.. "></textarea>
<input type="submit" value="Gem Description" class="submitDescription">
</form>
</div>
I have absolutely no idea what should be causing this. As I can make it show users full name, username, email etc. But not the bio, even though its printable. Anyone has any ideas?
Best regards
I wrongfully used the wrong object of my user model. I should of course use the session user.