이전 수업보단 좀더 편리한 방법

네임 스페이스를 등록

<html lang="en" xmlns:th="<http://www.thymeleaf.org>" xmlns:sec="<http://www.thymeleaf.org/extras/spring-security>">
<!DOCTYPE html>
<html lang="en" xmlns:th="<http://www.thymeleaf.org>" xmlns:sec="<http://www.thymeleaf.org/extras/spring-security>">
<head>
    <meta charset="UTF-8">
    <title>index</title>
</head>
<body>
    <h1 th:text="${message}">hello</h1>
    <div sec:authorize-expr="isAuthenticated()">
        <h2 sec:authentication="name">Name</h2>
        <a href="/logout" th:href="@{/logout}">Logout</a>
    </div>
    <div sec:authorize-expr="!isAuthenticated()">
        <a href="/login" th:href="@{/login}">Login</a>
    </div>
</body>
</html>