JSP에 다음과 같이 사용
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
로그인 안 한 사용자(isAnonymous())
<sec:authorize access="isAnonymous()">
<a class="nav-link dropdown-toggle text-nowrap px-3" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">
<img class="user-avatar rounded-circle mr-2" src="/resources/shards/images/avatars/0.jpg" alt="User Avatar">
<span class="d-none d-md-inline-block">로그인해주세요</span>
</a>
</sec:authorize>
로그인 한 사용자(isAuthenticated())
<!-- 로그인 한 사용자의 경우
principal.user => CusVO(로그인 시 CustomerUser에서 세팅된 정보)
-->
<sec:authorize access="isAuthenticated()">
<sec:authentication property="principal.user.cusNm"/>
(<sec:authentication property="principal.user.username"/>)님
<form method="post" action="/logout">
<button type="submit" class="mb-2 btn btn-sm btn-outline-info mr-1">로그아웃</button>
<sec:csrfInput/>
</form>
</sec:authorize>
출력화면 :
로그인 안 한 사용자
로그인 한 사용자