스프링 시큐리티 실습 중
로그인 성공시 해당 Role에 맞는 페이지로 리다이렉트 시켜주는 과정에서
404가 떴다.
아무리 봐도 매핑이 맞는데...뭐가 문젠지 해서 url창을 보니
http://localhost:8090/kosa/security/admin <- 이게 올바른 주소인데
내 리다이렉트는
http://localhost:8090/security/admin < - 이 주소로 가서 404가 나오는 것이었다.
if(roleNames.contains("ROLE_ADMIN")) {
response.sendRedirect(request.getContextPath() +"/security/admin");
return;
}
if(roleNames.contains("ROLE_MEMBER")) {
response.sendRedirect(request.getContextPath() +"/security/member");
return;
}
위와 같이 request.getContextPath()로 만들어주니 정상적인 주소로 Redirect됐다.
리다이렉트에선 contextPath가 자동으로 붙지 않는 모양이다...
'개발' 카테고리의 다른 글
@PreAuthorize("isAuthenticated()") not working (0) | 2023.01.24 |
---|---|
[에러일기] mapper 의존성주입 (0) | 2023.01.22 |
[에러일기]BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext (0) | 2023.01.12 |
[에러일기]NoSuchBeanDefinitionException: No qualifying bean of type (1) | 2023.01.11 |
@RestController (0) | 2023.01.11 |