1. spring 6.0.9 + thymeleaf4
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.thymeleaf.spring6.templateresolver.SpringResourceTemplateResolver;
@Configuration
public class ThymeleafConfig {
@Bean
public Thymeleaf4Properties thymeleaf4Properties() {
return new Thymeleaf4Properties();
}
@Bean
public SpringResourceTemplateResolver thymeleafTemplateResolver(
SpringResourceTemplateResolver defaultTemplateResolver,
Thymeleaf4Properties thymeleaf4Properties
) {
defaultTemplateResolver.setUseDecoupledLogic(thymeleaf4Properties.decoupledLogic());
return defaultTemplateResolver;
}
@Getter
@RequiredArgsConstructor
@ConfigurationProperties("spring.thymeleaf4")
public static class Thymeleaf4Properties {
/**
* Use Thymeleaf 4 Decoupled Logic
*/
public boolean decoupledLogic() {
return false;
}
}
}
2. Thymeleaf의 decoupled logic
decoupled(분리된) logic은 thymeleaf의 기능하나로 html 과 xml 템플릿에서 순수 마크업과 로직이 들어간 부분을 분리시키는 기능이다.
index.th.xml
<?xml version="1.0" encoding="utf-8" ?>
<thlogic>
<attr sel ="header" th:replace="header :: header"/>
<attr sel ="footer" th:replace="footer :: footer"/>
</thlogic>
'JAVA&Spring > Settting' 카테고리의 다른 글
SecurityConfig (0) | 2023.06.27 |
---|---|
qusydsl gradle 설정 (0) | 2023.05.27 |