Ao inserir o username e o password obtenho o erro:
There was an unexpected error (type=Not Found, status=404). No message available
Código:
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
public void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.anyRequest().authenticated()
.and()
.formLogin(form -> form
.loginPage("/login")
.permitAll());
}
@Bean
@Override
protected UserDetailsService userDetailsService() {
UserDetails user =
User.withDefaultPasswordEncoder()
.username("joao")
.password("joao")
.roles("ADM")
.build();
return new InMemoryUserDetailsManager(user);
}@Controller
public class LoginController {
@GetMapping
@RequestMapping("/login")
public String login() {
return "login";
}
}<html>
<head th:replace="~{base :: head}"></head>
<body>
<div th:replace="~{base :: logo}"></div>
<div class="container">
<div th:replace="~{base :: titulo('Login')}"></div>
<div class="card mb-3">
<form th:action="@{/login}" method="post">
<div class="form-group">
<label for="username">Usuário</label>
<input name="username" class="form-control" placeholder="usuário" />
</div>
<div class="form-group">
<label for="password">Senha</label>
<input type="password" name="password" class="form-control" placeholder="senha" />
</div>
<button class="btn btn-primary" type="submit"> Login </button>
</form>
</div>
</div>
</body>
</html>