try to fix template resolvers
This commit is contained in:
parent
9ec7b42972
commit
7089bd6c42
@ -1,21 +1,33 @@
|
||||
package ru.ulstu.configuration;
|
||||
|
||||
import nz.net.ultraq.thymeleaf.LayoutDialect;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.thymeleaf.extras.springsecurity4.dialect.SpringSecurityDialect;
|
||||
import org.thymeleaf.spring4.SpringTemplateEngine;
|
||||
import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver;
|
||||
import org.thymeleaf.templateresolver.ITemplateResolver;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
@Configuration
|
||||
public class MailTemplateConfiguration {
|
||||
@Bean
|
||||
public SpringTemplateEngine templateEngine(ITemplateResolver templateResolver, SpringSecurityDialect sec) {
|
||||
final SpringTemplateEngine templateEngine = new SpringTemplateEngine();
|
||||
templateEngine.addTemplateResolver(templateResolver);
|
||||
templateEngine.addTemplateResolver(emailTemplateResolver());
|
||||
templateEngine.addDialect(new LayoutDialect());
|
||||
templateEngine.addDialect(sec);
|
||||
return templateEngine;
|
||||
}
|
||||
|
||||
public ClassLoaderTemplateResolver emailTemplateResolver() {
|
||||
ClassLoaderTemplateResolver emailTemplateResolver = new ClassLoaderTemplateResolver();
|
||||
emailTemplateResolver.setPrefix("mail_templates/");
|
||||
emailTemplateResolver.setSuffix(".html");
|
||||
emailTemplateResolver.setPrefix("/mail_templates/");
|
||||
emailTemplateResolver.setTemplateMode("HTML5");
|
||||
emailTemplateResolver.setCharacterEncoding(StandardCharsets.UTF_8.name());
|
||||
emailTemplateResolver.setOrder(1);
|
||||
return emailTemplateResolver;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user