#linking login info to database
1 messages · Page 1 of 1 (latest)
<@&987246584574140416> please have a look, thanks.
What do you mean link it to a database? You mean you want to store the info in say a MySQL db?
show your code
If you're a beginner, you'd better start with the basics of java and then move on to web development. I'll assume you're already using Spring, so you need:
- Create table in your db like 'users'
- Create User entity with @Entity annotation and declare all columns of 'users' table
- [Optional] Create UserCreateDto/UserReadDto, if you worrying about security.
- Create controllers layer to handling requests
- Also, don't forget to declar the dependency to your DB in build.gradle/xml
After that, I recommend using Thymeleaf to link controller and your login page
login.html:
<form th:action="@{/login}" method="post">
//code-code-code...
</form>
UserController:
@Controller
@RequiredArgsConstructor
public class UserCreateController {
@GetMapping("/login")
public String loginPage() {
return "user/login";
}
}
Detected code, here are some useful tools:
Okay so lets take a few steps back
give more context on your problem