Search in sources :

Example 1 with ThymeleafViewResolver

use of org.thymeleaf.spring5.view.ThymeleafViewResolver in project gs-spring-security-3.2 by rwinch.

the class WebMvcConfiguration method viewResolver.

@Bean
public ThymeleafViewResolver viewResolver(SpringTemplateEngine templateEngine) {
    ThymeleafViewResolver viewResolver = new ThymeleafViewResolver();
    viewResolver.setTemplateEngine(templateEngine);
    viewResolver.setViewClass(ThymeleafTilesView.class);
    viewResolver.setCache(false);
    return viewResolver;
}
Also used : ThymeleafViewResolver(org.thymeleaf.spring4.view.ThymeleafViewResolver) Bean(org.springframework.context.annotation.Bean)

Example 2 with ThymeleafViewResolver

use of org.thymeleaf.spring5.view.ThymeleafViewResolver in project spring-security by spring-projects.

the class WebMvcConfiguration method viewResolver.

@Bean
public ViewResolver viewResolver() {
    ThymeleafViewResolver resolver = new ThymeleafViewResolver();
    resolver.setTemplateEngine(templateEngine());
    resolver.setCharacterEncoding("UTF-8");
    return resolver;
}
Also used : ThymeleafViewResolver(org.thymeleaf.spring4.view.ThymeleafViewResolver) Bean(org.springframework.context.annotation.Bean)

Example 3 with ThymeleafViewResolver

use of org.thymeleaf.spring5.view.ThymeleafViewResolver in project spring-boot by spring-projects.

the class ThymeleafAutoConfigurationTests method overrideViewNames.

@Test
public void overrideViewNames() throws Exception {
    EnvironmentTestUtils.addEnvironment(this.context, "spring.thymeleaf.viewNames:foo,bar");
    this.context.register(ThymeleafAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class);
    this.context.refresh();
    ThymeleafViewResolver views = this.context.getBean(ThymeleafViewResolver.class);
    assertThat(views.getViewNames()).isEqualTo(new String[] { "foo", "bar" });
}
Also used : ThymeleafViewResolver(org.thymeleaf.spring5.view.ThymeleafViewResolver) Test(org.junit.Test)

Example 4 with ThymeleafViewResolver

use of org.thymeleaf.spring5.view.ThymeleafViewResolver in project spring-boot by spring-projects.

the class ThymeleafAutoConfigurationTests method overrideCharacterEncoding.

@Test
public void overrideCharacterEncoding() throws Exception {
    EnvironmentTestUtils.addEnvironment(this.context, "spring.thymeleaf.encoding:UTF-16");
    this.context.register(ThymeleafAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class);
    this.context.refresh();
    ITemplateResolver resolver = this.context.getBean(ITemplateResolver.class);
    assertThat(resolver instanceof SpringResourceTemplateResolver).isTrue();
    assertThat(((SpringResourceTemplateResolver) resolver).getCharacterEncoding()).isEqualTo("UTF-16");
    ThymeleafViewResolver views = this.context.getBean(ThymeleafViewResolver.class);
    assertThat(views.getCharacterEncoding()).isEqualTo("UTF-16");
    assertThat(views.getContentType()).isEqualTo("text/html;charset=UTF-16");
}
Also used : SpringResourceTemplateResolver(org.thymeleaf.spring5.templateresolver.SpringResourceTemplateResolver) ITemplateResolver(org.thymeleaf.templateresolver.ITemplateResolver) ThymeleafViewResolver(org.thymeleaf.spring5.view.ThymeleafViewResolver) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 Bean (org.springframework.context.annotation.Bean)2 ThymeleafViewResolver (org.thymeleaf.spring4.view.ThymeleafViewResolver)2 ThymeleafViewResolver (org.thymeleaf.spring5.view.ThymeleafViewResolver)2 SpringResourceTemplateResolver (org.thymeleaf.spring5.templateresolver.SpringResourceTemplateResolver)1 ITemplateResolver (org.thymeleaf.templateresolver.ITemplateResolver)1