본문 바로가기

FRONTEND/Thymeleaf

session에 저장한 값 thymeleaf에서 불러오기

fors.tistory.com/437

 

컨트롤러에서 지정한 세션 값 타임리프에서 읽기

컨트롤러에서는 이렇게 세션에 값을 추가 할 수 있다. 1 2 HttpSession session = (HttpSession)request.getSession(); session.setAttribute("loginUser", loginUser); cs 이제 타임 리프에서 찾아본다. 이렇..

fors.tistory.com

Controller

String str = "";
request.getSession().setAttribute("admin", str);

 

 

html

<span th:text="'[관리자] ' + ${session.admin}">[관리자] 192.168.0.1</span>

'FRONTEND > Thymeleaf' 카테고리의 다른 글

자주쓰던 Thymeleaf  (0) 2021.06.18
타임리프 숫자 포매팅  (0) 2021.04.30
thymeleaf split  (0) 2021.04.08
Thymeleaf <br>로  (0) 2021.04.05
타임리프 조건검사  (0) 2021.01.14