Sung
Sung
Explore posts from servers
JCHJava Community | Help. Code. Learn.
Created by Sung on 10/23/2024 in #java-help
[ GITHUB ]Contrib graph not working
Hello, I don't know hy but my contrib graph doesn't work when I commit and push, it obviously work when I'm using github to delete or add a repo but github doesn't count my commits. I have always had a different email in my signature from my github and my commit signature and it used to work before. I tried to modify my mail with a git command line to have the exact same email but there's an SSH key and it tells me the key is invalid. Anyone can help me with that ?
6 replies
JCHJava Community | Help. Code. Learn.
Created by Sung on 8/6/2024 in #java-help
Thymeleaf / Loading image from DTO
Hello guys, I'm trying to make a profile manager for any user that is successfully identified, I can render every user datas in my template except for my image, in my inspector it says the image can't load The image comes from my DTO and it's persisted in my database and I have implemented my getters and setters properly but I still don't know why it doesn't work. In my browser it obviously shows Image de profil Here's my code in my template :
<h1 th:if="${user != null}">Profil de <span th:text="${user.firstName}"></span></h1>
<h1 th:if="${user != null}">Profil de <span th:text="${user.lastName}"></span></h1>
<h1 th:if="${user != null}">Profil de <span th:text="${user.email}"></span></h1>

<div th:if="${user != null}">
<img th:src="${user.image}" alt="Image de profil" width="400px"/>
</div>

<h1 th:if="${user == null}">Profil de <span th:text="${error}">User not found !!!</span></h1>
<h1 th:if="${user != null}">Profil de <span th:text="${user.firstName}"></span></h1>
<h1 th:if="${user != null}">Profil de <span th:text="${user.lastName}"></span></h1>
<h1 th:if="${user != null}">Profil de <span th:text="${user.email}"></span></h1>

<div th:if="${user != null}">
<img th:src="${user.image}" alt="Image de profil" width="400px"/>
</div>

<h1 th:if="${user == null}">Profil de <span th:text="${error}">User not found !!!</span></h1>
22 replies
JCHJava Community | Help. Code. Learn.
Created by Sung on 7/29/2024 in #java-help
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/[email protected] ( 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";
}
@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";
}
21 replies
JCHJava Community | Help. Code. Learn.
Created by Sung on 7/25/2024 in #java-help
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>
10 replies
JCHJava Community | Help. Code. Learn.
Created by Sung on 7/20/2024 in #java-help
Spring Boot Security / Request = 500
Hello guys, I'm a beginner here who's trying Spring Boot security. I'm trying to sign in with the httpSecurity but when I do my sign-in request, SPring boot redirects me to the famous
Whitelabel Error Page

This application has no explicit mapping for /error, so you are seeing this as a fallback.
Sat Jul 20 23:12:55 CEST 2024
There was an unexpected error (type=Internal Server Error, status=500).
Whitelabel Error Page

This application has no explicit mapping for /error, so you are seeing this as a fallback.
Sat Jul 20 23:12:55 CEST 2024
There was an unexpected error (type=Internal Server Error, status=500).
issue. The thing is in my security configuration I understand I have to modify this line :
.formLogin(form -> form

// Redirect the user if successfull authentication
.defaultSuccessUrl("/",true)

)
.logout(config-> config.logoutSuccessUrl("/"))
// Redirect the user if log the fuck out
.build();
.formLogin(form -> form

// Redirect the user if successfull authentication
.defaultSuccessUrl("/",true)

)
.logout(config-> config.logoutSuccessUrl("/"))
// Redirect the user if log the fuck out
.build();
But my home URL is http://localhost:8080/ do you know how to modify the url to at least redirect it to the homepage ( I built my environment with Maven ) ?
94 replies