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

The following examples show how to use org.thymeleaf.spring5.view.ThymeleafViewResolver#setCache() . 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: WebConfig.java    From Spring5Tutorial with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Bean
public ViewResolver viewResolver(SpringTemplateEngine engine) {
    // 建立ViewResolver實作物件並設置模版引擎實例
    ThymeleafViewResolver resolver = new ThymeleafViewResolver();
    resolver.setTemplateEngine(engine);
    // 回應內容編碼
    resolver.setCharacterEncoding("UTF-8");
    resolver.setCache(false);
    return resolver;
}
 
Example 2
Source File: WebConfig.java    From Spring5Tutorial with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Bean
public ViewResolver viewResolver(SpringTemplateEngine engine) {
    ThymeleafViewResolver resolver = new ThymeleafViewResolver();
    resolver.setTemplateEngine(engine);
    resolver.setCharacterEncoding("UTF-8");
    resolver.setCache(false);
    return resolver;
}
 
Example 3
Source File: WebConfig.java    From Spring5Tutorial with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Bean
public ViewResolver viewResolver(SpringTemplateEngine engine) {
    ThymeleafViewResolver resolver = new ThymeleafViewResolver();
    resolver.setTemplateEngine(engine);
    resolver.setCharacterEncoding("UTF-8");
    resolver.setCache(false);
    return resolver;
}
 
Example 4
Source File: WebConfig.java    From Spring5Tutorial with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Bean
public ViewResolver viewResolver(SpringTemplateEngine engine) {
    ThymeleafViewResolver resolver = new ThymeleafViewResolver();
    resolver.setTemplateEngine(engine);
    resolver.setCharacterEncoding("UTF-8");
    resolver.setCache(false);
    return resolver;
}
 
Example 5
Source File: WebConfig.java    From Spring5Tutorial with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Bean
public ViewResolver viewResolver(SpringTemplateEngine engine) {
    ThymeleafViewResolver resolver = new ThymeleafViewResolver();
    resolver.setTemplateEngine(engine);
    resolver.setCharacterEncoding("UTF-8");
    resolver.setCache(false);
    return resolver;
}
 
Example 6
Source File: WebConfig.java    From Spring5Tutorial with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Bean
public ViewResolver viewResolver(SpringTemplateEngine engine) {
    ThymeleafViewResolver resolver = new ThymeleafViewResolver();
    resolver.setTemplateEngine(engine);
    resolver.setCharacterEncoding("UTF-8");
    resolver.setCache(false);
    return resolver;
}
 
Example 7
Source File: WebConfig.java    From Spring5Tutorial with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Bean
public ViewResolver viewResolver(SpringTemplateEngine engine) {
    // 建立ViewResolver實作物件並設置模版引擎實例
    ThymeleafViewResolver resolver = new ThymeleafViewResolver();
    resolver.setTemplateEngine(engine);
    // 回應內容編碼
    resolver.setCharacterEncoding("UTF-8");
    resolver.setCache(false);
    return resolver;
}
 
Example 8
Source File: WebConfig.java    From Spring5Tutorial with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Bean
public ViewResolver viewResolver(SpringTemplateEngine engine) {
    // 建立ViewResolver實作物件並設置模版引擎實例
    ThymeleafViewResolver resolver = new ThymeleafViewResolver();
    resolver.setTemplateEngine(engine);
    // 回應內容編碼
    resolver.setCharacterEncoding("UTF-8");
    resolver.setCache(false);
    return resolver;
}
 
Example 9
Source File: WebConfig.java    From Spring5Tutorial with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Bean
public ViewResolver viewResolver(SpringTemplateEngine engine) {
    // 建立ViewResolver實作物件並設置模版引擎實例
    ThymeleafViewResolver resolver = new ThymeleafViewResolver();
    resolver.setTemplateEngine(engine);
    // 回應內容編碼
    resolver.setCharacterEncoding("UTF-8");
    resolver.setCache(false);
    return resolver;
}
 
Example 10
Source File: WebConfig.java    From Spring5Tutorial with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Bean
public ViewResolver viewResolver(SpringTemplateEngine engine) {
    // 建立ViewResolver實作物件並設置模版引擎實例
    ThymeleafViewResolver resolver = new ThymeleafViewResolver();
    resolver.setTemplateEngine(engine);
    // 回應內容編碼
    resolver.setCharacterEncoding("UTF-8");
    resolver.setCache(false);
    return resolver;
}
 
Example 11
Source File: WebConfig.java    From Spring5Tutorial with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Bean
public ViewResolver viewResolver(SpringTemplateEngine engine) {
    ThymeleafViewResolver resolver = new ThymeleafViewResolver();
    resolver.setTemplateEngine(engine);
    resolver.setCharacterEncoding("UTF-8");
    resolver.setCache(false);
    return resolver;
}
 
Example 12
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 13
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 14
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 15
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;
}
 
Example 16
Source File: WebMvcConfig.java    From spring-comparing-template-engines with Apache License 2.0 5 votes vote down vote up
@Bean
public ViewResolver thymeleafViewResolver() {
	ThymeleafViewResolver viewResolver = new ThymeleafViewResolver();
	viewResolver.setViewNames(new String[] { "*-thymeleaf" });
	viewResolver.setTemplateEngine(thymeleafTemplateEngine());
	viewResolver.setCharacterEncoding("UTF-8");
	viewResolver.setCache(false);

	return viewResolver;
}