본문 바로가기

Tip/Spring

[Thymeleaf] Thymol Static Imports

제목에서 말하듯 Thymeleaf 를 사용시 Thymol 을 통해 html 파일에서의 정적임포트가 가능하다. Thymeleaf 를 이용하여 include 한 파일을 jquery 의 get() 을 통해 해당 위치를 태그를 대체하는 형태로 동작하는데 크롬에서는 다음과 같은 에러를 발생하며 작동하지 않는다. (버전 28.0.1500.95 m)


Failed to load resource: Origin null is not allowed by Access-Control-Allow-Origin. file:///C:/dev/workspace/proj1/src/main/webapp/WEB-INF/views/common/menu.html


이때 해당 사이트에서 제시한 아래의 방법을 적용하면 정적인 임포트가 가능하다. 그렇다고 Thymeleaf 의 모든 include 를 지원하는 것은 아니다. 퍼블리셔가 공통으로 작성한 html 에 대한 include 정도(?)라고 보면 될것 같다. 스크립트 공통 선언과 관련해서는 좀 더 찾아봐야 하겠다. 


e.g. <path-to-chrome-home>chrome.exe --allow-file-access-from-files



  참고


Thymol Static Importshttp://sourceforge.net/u/jjbenson/wiki/thymol/#static-imports


Thymol Browser Constraintshttp://sourceforge.net/u/jjbenson/wiki/thymol/#browser-constraints