처음에 보여준 화면처럼 보여줌
main.html
<!-- 로그인이 되어있지 않은 경우 -->
<th:block th:if="${session.loginMember == null}">
<!-- 로그인 박스 -->
<form action="/member/login" method="POST" id="loginForm">
<fieldset class="id-pw-area">
<!-- 아이디/비밀번호 입력 -->
<section>
<input type="text"
name="memberEmail"
placeholder="이메일">
<input type="password"
name="memberPw"
placeholder="비밀번호">
</section>
<!-- 로그인 버튼 -->
<section>
<button>로그인</button>
</section>
</fieldset>
<label>
<!-- label 태그 : input 태그의 제목을 나타내는 태그 -->
<input type="checkbox" name="saveId">
아이디 저장
</label>
<article class="signup-find-area">
<a href="/member/signup">회원가입</a>
<span> | </span>
<a href="#">ID/PW 찾기</a>
</article>
</form>
</th:block>

main.html
<!-- 로그인이 되어있는 경우 -->
<th:block th:if="${session.loginMember != null}">
위에 th:if 와 같은 뜻
<th:block th:unless="${session.loginMember == null}"></th:block>
회원가입 할 당시 기본으로 쓸 이미지 static images 에 user.png 올려둠
messages.properties 에 작성된 기본 사용자 이미지
<article class="login-area">
<a href="/myPage/profile">
<!-- 프로필 이미지 -->
<img th:with="user=#{user.default.image}"
th:src="${session.loginMember.profileImg ?: user}"
id="memberProfile"
alt="프로필 이미지"
>
</a>
session.loginMember.profileImg 가 null이 아니면 session.loginMember.profileImg에 저장된 이미지 경로가 들어가고 null 이면 user가 들어감
th:with 변수 만드는 거 user 라는 변수명에 /images/user.png 넣어준 거
<!-- 닉네임, 이메일, 로그아웃 버튼 영역 -->
<div class="my-info" th:object="${session.loginMember}">
<div>
<a href="/myPage/info" id="nickname" th:text="*{memberNickname}">닉네임</a>
<a href="/member/logout" id="logoutBtn">로그아웃</a>
</div>
<p th:text="*{memberEmail}">이메일</p>
</div>
</article>
</th:block>

main.html
<a href="/member/logout" id="logoutBtn">로그아웃</a>
Controller 에서 받아서 바로 처리해줌
세션을 완료(없앰) 시키는 역할의 객체
(현재 세션의 상태를 다룰 수 있는 거)
MemberController
@GetMapping("logout")
public String logout(SessionStatus status) {
status.setComplete(); // 세션을 완료 시킴(없앰)
// 메인페이지 리다이렉트
return "redirect:/";
}