관리 메뉴

HeBhy, since 1983.

Thymeleaf 3.x 이상 사용 주의사항 (over Spring security 5.x) 본문

Dev/Web

Thymeleaf 3.x 이상 사용 주의사항 (over Spring security 5.x)

HeBhy 2018. 10. 30. 13:07

1. <html> 태그에서 layout:decorator="html명" -> layout:decorate="~{html명}" 으로 바뀌었다.


2. 레이아웃 html의 <head></head> 태그 안에 <th:block layout:fragment="script"> 같은 태그를 쓸 필요 없이 실 컨텐츠 페이지에서 <head> 태그 안에 <title> 나 자바스크립트, css등을 그냥 쓰면 레이아웃의 <head>내의 태그에 덧붙여 자동으로 추가된다.(title은 덮어쓰기된다)


3. Spring security 확장 플러그인 사용 시(repository), Spring boot 2.0.x에서는 아직 thymeleaf-extras-springsecurity4로 쓰고 html 파일 태그에서도 아래처럼 sec 4버전으로 지정해준다.

   (Spring boot 버전 2.1.x 에서는 thymeleaf-extras-springsecurity5로 하면 된다)


 xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4"


4. Spring security의 authentication 변수를 사용하려는데.. 그 안의 userDetail 정보를 얻을땐 아래처럼.. customUserDetail처럼 상속받은 경우도 가능. (아래 예제는 authentication.getPrincipal().getUser().getUserName()과 동일)

<span sec:authentication="principal.userName">




Comments