spring - 如何在 Spring Boot 中添加 thymeleaf 方言?

标签 spring spring-boot thymeleaf

我正在使用 Spring Boot,我想添加 IE conditional comments Thymeleaf dialect .

我已将它包含在我的 maven pom.xml 中,但它不起作用。我如何告诉 Thymeleaf 使用它?

最佳答案

注意:在尝试之前,请注意更高版本的 Spring Boot 包含一些开箱即用的常见方言。见@Robert Hunt 的 answer .否则:

有一个例子here添加方言 bean,Spring Boot 将自动检测和使用(参见 LayoutDialect 代码和 ThymeleafDefaultConfiguration 类的方言成员)。在您的情况下,在您的 @Configuration 类之一中添加以下内容:

@Bean
public ConditionalCommentsDialect conditionalCommentDialect() {
    return new ConditionalCommentsDialect();
}

Spring Boot,在 ThymeleafAutoConfiguration 类中,会自动添加任何实现 IDialect 接口(interface)的 Bean。

关于spring - 如何在 Spring Boot 中添加 thymeleaf 方言?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23531580/

相关文章:

java - Spring 添加 Cookie

Thymeleaf - 格式化时检查 NULL 的最佳实践(即日期)

java - Thymeleaf 选择标签导致异常

java - Spring Boot邮件忽略application.properties

java - "getOutputStream() has already been called for this response"会导致服务器崩溃吗?

eclipse - 无法在Jipster示例应用程序Gradle中运行Eclipse中的Junits

java - 使用 Jersey 实例化组件有什么好处

java - 为什么基本的 spring 4 示例不能使用 Eclipse kepler 运行?

eclipse - 从 Eclipse 中运行 Tomcat 总是给我 404(但 index.html 有效)

spring - 为 Rest Api 实现 Spring Security