
- jakarta.servlet.ServletException: Unable to handle the Spring Security Exception because the response is already committed.
- Caused by: org.springframework.security.access.AccessDeniedException: Access Denied
- Caused by: java.lang.IllegalArgumentException: The 'request','session','servletContext' and 'response' expression utility objects are no longer available by default for template expressions and their use is not recommended. In cases where they are really needed, they should be manually added as context variables.
네비바 부분에서 쿠키가 있다면 로그아웃, 없다면 로그인을 출력하고 싶었다.
th:if="${#request.getCookies()==null}
<li class="nav-item" th:if="${#request.getCookies()==null}">
<a class="nav-link" href="/user/login">로그인</a>
</li>
<li class="nav-item" th:if="${#request.getCookies()!= null}">
<a class="nav-link" href="/user/logout">로그아웃</a>
</li>
즉, 더이상 #request표현은 지원하지 않는다. 이용하고 싶으면 model attribute를 사용해야한다.
세션방식을 사용하지 않으니 타임리프에서 사용중인 spring-security 문법을 사용하지 못했다. 그래서 해결 방법을 찾던 중 서버 랜더링 방식은 타임리프를 사용하는 경우 jwt는 거의 사용하지 않는 다는 것이었다.
보통 jwt관리는 localStorage와 cookie를 이용해 관리하는데 spring boot에서 jsp, thymeleaf와 같은 ssr 기반 방식의 경우 jwt는 거의 사용하지 않는다.
ssr방식의 경우 대부분 세션-쿠키를 이용하여 상태관리를 한다.
1. localstorage방식은 불가능
2. cookie의 경우 보안, 복잡도, 생산성이 떨어짐
SSR의 경우 스프링 부트내에서 만들어진 controller를 이용해 서버에서 페이지를 반환하는 방식이다. jwt를 이용하려면 페이지 이동과 api 코드를 분리사용 해야하는데 코드의 복잡성이 높아진다.
생산성과 복잡도를 고려하여 jwt를 사용하려면 CSR(client-side rendering)방식이 적합하다.