에러
Caused by: org.attoparser.ParseException: Error during execution of processor 'org.thymeleaf.spring5.processor.SpringInputGeneralFieldTagProcessor' (template: "login_form" - line 39, col 40)
문제 파악
th:field 가 작동을 안함
스프링 시큐리티의 UsernamePasswordAuthenticationFilter가 요청을 가져감request.getParameter("username")과 request.getParameter("password")로 값을 추출
이 값들을 사용해 인증을 시도
왜 th가 작동하지 않는가?
로그인 폼에서 th:field를 사용하려면:
컨트롤러에서 모델에 객체를 추가해야 합니다.
이 객체는 membername과 password 필드를 가지고 있어야 합니다.
폼에 th:object를 사용해 객체를 바인딩해야 합니다.
해결:
하지만 스프링 시큐리티의 로그인 처리는 이런 방식으로 작동하지 않음. 로그인 폼을 보여주는 컨트롤러는 단순히 뷰 이름만 반환하고 모델 객체는 추가하지 x.
th:field가 참조할 객체가 없어서 오류가 발생
public class SecurityConfig {
@Bean
SecurityFilterChain filterChain(HttpSecurity http) throws Exception{
http
...
.formLogin((form) -> form
.loginPage("/member/login")
.defaultSuccessUrl("/")
.usernameParameter("membername") // username 파라미터명 변경
.passwordParameter("password") // password는 기본값 그대로 사용
.permitAll()
)


'【♣부트 캠프♣】 > ▷부캠- 에러 모음' 카테고리의 다른 글
| [24.06.27-29일차] PL/SQL: Compilation unit analysis terminated PLS-00201: identifier 'USERID' must be declared (0) | 2024.06.27 |
|---|---|
| [24.06.25-28일차] (0) | 2024.06.25 |
| [24.06.24-27일차] (0) | 2024.06.24 |
| [24.06.23- 26일차 에러] 도대체 왜 연결이 안되는건가 ORA-12505 에러?? (0) | 2024.06.23 |
| [24.06.18-22일차] 소재좀 떨어지면 좋겠다. (0) | 2024.06.18 |