pom.xml에 아래 dependency를 추가한다.
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-taglibs</artifactId>
<version>5.1.5.RELEASE</version>
</dependency>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<h1>User Detail Page</h1>
<p>principal: <sec:authentication property="principal"/></p>
<p>user: <sec:authentication property="principal.user"/></p>
<p>email: <sec:authentication property="principal.user.email"/></p>
<p>role: <sec:authentication property="principal.user.role"/></p>
<p>username: <sec:authentication property="principal.username"/></p>
<a href="/user/logout">Logout</a>
</body>
</html>
security-context.xml 파일의 일부
<security:http auto-config="true">
<security:intercept-url pattern="/user/join" access="permitAll" />
<security:intercept-url pattern="/user/login" access="permitAll" />
<security:intercept-url pattern="/admin/**" access="hasRole('ROLE_ADMIN')" />
<security:intercept-url pattern="/user/**" access="hasAnyRole('ROLE_USER', 'ROLE_ADMIN')" />
<security:form-login login-page="/user/login" login-processing-url="/user/login"
username-parameter="email" password-parameter="password" />
<security:access-denied-handler ref="customAccessDenied" />
<security:remember-me data-source-ref="dataSource" token-validity-seconds="604800" />
<security:logout invalidate-session="true" delete-cookies="remember-me, JSESSION_ID"
logout-url="/user/logout" logout-success-url="/" />
</security:http>