Render dynamic dayas / Status 400

Hello guys, I'm trying to render dynamically my datas from my entity ( the datas are well persisted, there's no problem in the database side ) with thymeleaf an user page once he's authenticated but I have the famous
Whitelabel Error Page

This application has no explicit mapping for /error, so you are seeing this as a fallback.
Wed Jul 24 16:43:43 CEST 2024
There was an unexpected error (type=Bad Request, status=400).
Whitelabel Error Page

This application has no explicit mapping for /error, so you are seeing this as a fallback.
Wed Jul 24 16:43:43 CEST 2024
There was an unexpected error (type=Bad Request, status=400).
I understand from my part this is a mapping problem, but I don't see what I didn't do wrong here's my code ( Controller part ) :
@GetMapping(value = "/profile") // I tried without value in my parameter
public String getUserProfile(Model model, @RequestParam String email){

AppUser user = repo.findByEmail(email);
if(user != null){
model.addAttribute("user", user);
}else{
model.addAttribute("error", "User not found");
}

return "profile";
}

@GetMapping(value = "/profile") // I tried without value in my parameter
public String getUserProfile(Model model, @RequestParam String email){

AppUser user = repo.findByEmail(email);
if(user != null){
model.addAttribute("user", user);
}else{
model.addAttribute("error", "User not found");
}

return "profile";
}

view part :
<!DOCTYPE html>
<html lang="en">
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.thymeleaf.org"></html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h1 th:if="{user != null}">Profil de <span th:text="${user.firstName}">user</span></h1>
<h1 th:if="{user == null}">Profil de <span th:text="${error}">User not found</span></h1>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.thymeleaf.org"></html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h1 th:if="{user != null}">Profil de <span th:text="${user.firstName}">user</span></h1>
<h1 th:if="{user == null}">Profil de <span th:text="${error}">User not found</span></h1>
</body>
</html>
6 Replies
JavaBot
JavaBotā€¢5mo ago
āŒ› This post has been reserved for your question.
Hey @NoSung! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here. šŸ’¤ Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
Peter Rader
Peter Raderā€¢4mo ago
Are you using maven? What is the URL you use?
Sung
SungOPā€¢4mo ago
Yes, Iā€™m using /profile Also I forgot the $ character in my thymeleaf condition but I still have the same error
Peter Rader
Peter Raderā€¢4mo ago
Please answer this question too mate.
Sung
SungOPā€¢4mo ago
I said it above
JavaBot
JavaBotā€¢4mo ago
šŸ’¤ Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
Want results from more Discord servers?
Add your server