티스토리 뷰

thymeleaf 템플릿 엔진을 사용 중에 meta, link, input 태그 등을 닫지 않으면 아래와 유사한 에러 메시지가 뜹니다.

org.xml.sax.SAXParseException: Open quote is expected for attribute “charset” associated with an element type “meta”.

thymeleaf의 기본 설정이 아래 처럼 HTML5로 설정되어 있기 때문입니다.

spring.thymeleaf.mode = HTML5

html 파일들을 webpack 등을 이용해 빌드를 하는 경우 등 수작업으로 맞춰주기가 귀찮거나 번거로운 경우에는 thymeleaf 모드를 legacy html5 모드로 변경해주면 됩니다.

thymeleaf를 legcay html5 모드로 사용하기 위해선 다음와 같이 설정하면 됩니다.

application.properties

spring.thymeleaf.mode=LEGACYHTML5

pom.xml

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
    <groupId>net.sourceforge.nekohtml</groupId>
    <artifactId>nekohtml</artifactId>
</dependency>


댓글