在application.properties文件中定义以下设置
spring.thymeleaf.templateResolverOrder=1
现在在您的自定义Bean中创建ITemplateResolver并将order和前缀和后缀设置为0,这样spring boot会监听两个地方
将顺序设置为0很重要
可以创建Bean的示例
@Bean public ClassLoaderTemplateResolver emailTemplateResolver() { ClassLoaderTemplateResolver emailTemplateResolver = new ClassLoaderTemplateResolver(); emailTemplateResolver.setPrefix("mails/"); emailTemplateResolver.setSuffix(".html"); emailTemplateResolver.setTemplateMode(TemplateMode.HTML); emailTemplateResolver.setCharacterEncoding("UTF-8"); emailTemplateResolver.setOrder(0); emailTemplateResolver.setCheckExistence(true); return emailTemplateResolver; }
我的例子
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)