Java Code Examples for org.thymeleaf.spring5.view.ThymeleafViewResolver#setOrder()

The following examples show how to use org.thymeleaf.spring5.view.ThymeleafViewResolver#setOrder() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SpringContextConfig.java    From Spring-5.0-Cookbook with MIT License 5 votes vote down vote up
@Bean(name="viewResolverThymeLeaf")
public ThymeleafViewResolver getViewResolverThyme(){
	ThymeleafViewResolver viewResolver = new ThymeleafViewResolver(); 
	viewResolver.setTemplateEngine(getTemplateEngine());
	viewResolver.setOrder(2);
	return viewResolver;
}
 
Example 2
Source File: SpringWebReactiveConfig.java    From Spring-5.0-Cookbook with MIT License 5 votes vote down vote up
@Bean(name="viewResolverThymeLeaf")
public ThymeleafViewResolver getViewResolverThyme(){
	ThymeleafViewResolver viewResolver = new ThymeleafViewResolver(); 
	viewResolver.setTemplateEngine(getTemplateEngine());
	viewResolver.setOrder(2);
	return viewResolver;
}
 
Example 3
Source File: SpringContextConfig.java    From Spring-5.0-Cookbook with MIT License 5 votes vote down vote up
@Bean(name="viewResolverThymeLeaf")
public ThymeleafViewResolver getViewResolverThyme(){
	ThymeleafViewResolver viewResolver = new ThymeleafViewResolver(); 
	viewResolver.setTemplateEngine(getTemplateEngine());
	viewResolver.setOrder(2);
	return viewResolver;
}
 
Example 4
Source File: MVCConfig.java    From convergent-ui with Apache License 2.0 5 votes vote down vote up
@Bean
public ThymeleafViewResolver thymeleafViewResolver(WebApplicationContext wac) {
    ThymeleafViewResolver resolver = new ThymeleafViewResolver();
    SpringTemplateEngine templateEngine = new SpringTemplateEngine();
    ServletContextTemplateResolver templateResolver = new ServletContextTemplateResolver(wac.getServletContext());
    templateResolver.setPrefix("/WEB-INF/templates/");
    templateResolver.setSuffix(".html");
    templateResolver.setTemplateMode("HTML");
    templateResolver.setCharacterEncoding("UTF-8");
    templateEngine.setTemplateResolver(templateResolver);
    resolver.setTemplateEngine(templateEngine);
    resolver.setOrder(2);
    resolver.setApplicationContext(wac);
    resolver.setCharacterEncoding("UTF-8");

    //Enable the Spring Security Thymeleaf integration
    templateEngine.addDialect(new LayoutDialect());

    // caching
    String[] activeProfiles = env.getActiveProfiles();
    if (Arrays.asList(activeProfiles).contains("dev")) {
        log.info("DEV Profile is active. Disabling template caching.");
        templateResolver.setCacheable(false);
        templateEngine.setCacheManager(null);
        resolver.setCache(false);
    }
    return resolver;
}
 
Example 5
Source File: MVCConfig.java    From convergent-ui with Apache License 2.0 5 votes vote down vote up
@Bean
public ThymeleafViewResolver thymeleafViewResolver(WebApplicationContext wac) {
    ThymeleafViewResolver resolver = new ThymeleafViewResolver();
    SpringTemplateEngine templateEngine = new SpringTemplateEngine();
    ServletContextTemplateResolver templateResolver = new ServletContextTemplateResolver(wac.getServletContext());
    templateResolver.setPrefix("/WEB-INF/templates/");
    templateResolver.setSuffix(".html");
    templateResolver.setTemplateMode("HTML");
    templateResolver.setCharacterEncoding("UTF-8");
    templateEngine.setTemplateResolver(templateResolver);
    resolver.setTemplateEngine(templateEngine);
    resolver.setOrder(2);
    resolver.setApplicationContext(wac);
    resolver.setCharacterEncoding("UTF-8");

    //Enable the Spring Security Thymeleaf integration
    templateEngine.addDialect(new LayoutDialect());

    // caching
    String[] activeProfiles = env.getActiveProfiles();
    if (Arrays.asList(activeProfiles).contains("dev")) {
        log.info("DEV Profile is active. Disabling template caching.");
        templateResolver.setCacheable(false);
        templateEngine.setCacheManager(null);
        resolver.setCache(false);
    }
    return resolver;
}
 
Example 6
Source File: WallRideThymeleafConfiguration.java    From wallride with Apache License 2.0 5 votes vote down vote up
@Bean
public ThymeleafViewResolver thymeleafViewResolver(SpringTemplateEngine templateEngine) {
	ThymeleafViewResolver viewResolver = new ExtendedThymeleafViewResolver();
	viewResolver.setTemplateEngine(templateEngine);
	viewResolver.setViewNames(this.thymeleafProperties.getViewNames());
	viewResolver.setCharacterEncoding(this.thymeleafProperties.getEncoding().name());
	viewResolver.setContentType(this.thymeleafProperties.getServlet().getContentType() + ";charset=" + this.thymeleafProperties.getEncoding());
	viewResolver.setCache(false);
	viewResolver.setOrder(2);
	return viewResolver;
}
 
Example 7
Source File: WebAdminConfiguration.java    From wallride with Apache License 2.0 5 votes vote down vote up
@Bean
public ThymeleafViewResolver thymeleafViewResolver() {
	ThymeleafViewResolver viewResolver = new ExtendedThymeleafViewResolver();
	viewResolver.setTemplateEngine(templateEngine());
	viewResolver.setViewNames(this.properties.getViewNames());
	viewResolver.setCharacterEncoding(this.properties.getEncoding().name());
	viewResolver.setContentType(this.properties.getServlet().getContentType() + ";charset=" + this.properties.getEncoding());
	viewResolver.setCache(false);
	viewResolver.setOrder(1);
	return viewResolver;
}