RequestParam / User Not Found

Hello again guys,

I'd like to render my data user on a template with the GET method. I made sure my page was created and my datas are persisted in my db.

I tried to render my data through the email user as it's shown below and I want my URL to be like this : http://localhost:8080/profile?email=test@test.com ( which works perfectly if I write this in my browser bar ) but when I want to access to my profile it return me a USer nto found, because Spring boot sees it as null

 @GetMapping("/profile")
        public String getUserProfile(Model model, @RequestParam(required = false) String email){
            
            AppUser user = repo.findByEmail(email);
            System.out.println("the email is :" + email);
            if(user != null){
                model.addAttribute("user", user);
            }else{
                model.addAttribute("error", "User not found");
            }

            return "profile";
        }
Was this page helpful?