當前位置: 首頁>>代碼示例>>Java>>正文


Java ServletContextTemplateResolver類代碼示例

本文整理匯總了Java中org.thymeleaf.templateresolver.ServletContextTemplateResolver的典型用法代碼示例。如果您正苦於以下問題:Java ServletContextTemplateResolver類的具體用法?Java ServletContextTemplateResolver怎麽用?Java ServletContextTemplateResolver使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ServletContextTemplateResolver類屬於org.thymeleaf.templateresolver包,在下文中一共展示了ServletContextTemplateResolver類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: init

import org.thymeleaf.templateresolver.ServletContextTemplateResolver; //導入依賴的package包/類
@Override
public void init() {
  // Setup ThymeLeaf
  ServletContextTemplateResolver templateResolver =
      new ServletContextTemplateResolver(this.getServletContext());

  templateResolver.setPrefix("/WEB-INF/templates/");
  templateResolver.setSuffix(".html");
  templateResolver.setCacheTTLMs(Long.valueOf(1200000L)); // TTL=20m

  // Cache is set to true by default. Set to false if you want templates to
  // be automatically updated when modified.
  templateResolver.setCacheable(true);

  templateEngine = new TemplateEngine();
  templateEngine.setTemplateResolver(templateResolver);
}
 
開發者ID:GoogleCloudPlatform,項目名稱:java-docs-samples,代碼行數:18,代碼來源:GaeInfoServlet.java

示例2: init

import org.thymeleaf.templateresolver.ServletContextTemplateResolver; //導入依賴的package包/類
/**
 * Initialize the Thymeleaf template engine.
 */
@Override
public void init() {
	ServletConfig config = this.getServletConfig();

	ServletContextTemplateResolver templateresolver = new ServletContextTemplateResolver();
	templateresolver.setPrefix(config.getInitParameter(INIT_PARAM_PREFIX));
	templateresolver.setSuffix(config.getInitParameter(INIT_PARAM_SUFFIX));
	templateresolver.setTemplateMode(config.getInitParameter(INIT_PARAM_TEMPLATEMODE));
	templateresolver.setCacheable(false);
	templateresolver.setCharacterEncoding(CHARACTER_ENCODING);

	templateengine = new TemplateEngine();
	templateengine.setTemplateResolver(templateresolver);
       Set<IDialect> dialects = new HashSet<IDialect>();
	dialects.add(new SpringStandardDialect());
	dialects.add(new SqlDialect());
       templateengine.setDialects(dialects);
       templateengine.initialize();
}
 
開發者ID:jmiguelsamper,項目名稱:thymeleaf-extras-sqldialect,代碼行數:23,代碼來源:StandaloneThymeleafServlet.java

示例3: get

import org.thymeleaf.templateresolver.ServletContextTemplateResolver; //導入依賴的package包/類
@Override
public ITemplateResolver get()
{
	ServletContextTemplateResolver resolver = new ServletContextTemplateResolver();

	resolver.setTemplateMode("HTML5");

	// Load templates from WEB-INF/templates/{name}.html
	resolver.setPrefix("/WEB-INF/template/");
	resolver.setSuffix(".html");

	if (cacheTTL.getMilliseconds() > 0)
	{
		// cache templates for an hour
		resolver.setCacheTTLMs(cacheTTL.getMilliseconds());
		resolver.setCacheable(true);
	}
	else
	{
		// Don't cache
		resolver.setCacheable(false);
	}

	return resolver;
}
 
開發者ID:petergeneric,項目名稱:stdlib,代碼行數:26,代碼來源:TemplateResolverProvider.java

示例4: getTemplateResolver

import org.thymeleaf.templateresolver.ServletContextTemplateResolver; //導入依賴的package包/類
/**
 * Bean to get the template resolver
 *
 * @return the template resolver
 */
@Bean(name = "templateResolver")
public ServletContextTemplateResolver getTemplateResolver() {
    final ServletContextTemplateResolver templateResolver = new ServletContextTemplateResolver();
    templateResolver.setPrefix("/WEB-INF/templates/");
    templateResolver.setSuffix(".html");
    templateResolver.setTemplateMode("XHTML");
    return templateResolver;
}
 
開發者ID:mhaddon,項目名稱:Sound.je,代碼行數:14,代碼來源:TemplateConfig.java

示例5: templateResolver

import org.thymeleaf.templateresolver.ServletContextTemplateResolver; //導入依賴的package包/類
@Bean
public ServletContextTemplateResolver templateResolver() {
    ServletContextTemplateResolver resolver = new ServletContextTemplateResolver();
    resolver.setPrefix("/WEB-INF/templates/");
    resolver.setSuffix(".html");
    resolver.setTemplateMode("HTML5");
    resolver.setCacheable(false);
    resolver.setOrder(1);
    return resolver;
}
 
開發者ID:PacktPublishing,項目名稱:Spring-Security-Third-Edition,代碼行數:11,代碼來源:ThymeleafConfig.java

示例6: templateEngine

import org.thymeleaf.templateresolver.ServletContextTemplateResolver; //導入依賴的package包/類
@Bean
    public SpringTemplateEngine templateEngine(final ServletContextTemplateResolver templateResolver) {
        SpringTemplateEngine engine = new SpringTemplateEngine();
        engine.setTemplateResolver(templateResolver);
//        engine.setEnableSpringELCompiler(true);

        engine.setAdditionalDialects(new HashSet<IDialect>() {{
            add(new LayoutDialect());
            add(new SpringSecurityDialect());
        }});
        return engine;
    }
 
開發者ID:PacktPublishing,項目名稱:Spring-Security-Third-Edition,代碼行數:13,代碼來源:ThymeleafConfig.java

示例7: templateResolver

import org.thymeleaf.templateresolver.ServletContextTemplateResolver; //導入依賴的package包/類
@Bean
    public ServletContextTemplateResolver templateResolver() {
        ServletContextTemplateResolver resolver = new ServletContextTemplateResolver();
        resolver.setPrefix("/WEB-INF/templates/");
        resolver.setSuffix(".html");
//        resolver.setTemplateMode("HTML5");
        resolver.setCacheable(false);
        resolver.setOrder(1);
        return resolver;
    }
 
開發者ID:PacktPublishing,項目名稱:Spring-Security-Third-Edition,代碼行數:11,代碼來源:ThymeleafConfig.java

示例8: getTemplateEngine

import org.thymeleaf.templateresolver.ServletContextTemplateResolver; //導入依賴的package包/類
@Produces
@ViewEngineConfig
public TemplateEngine getTemplateEngine() {

    ITemplateResolver resolver = new ServletContextTemplateResolver(this.servletContext);

    TemplateEngine engine = new TemplateEngine();
    engine.setTemplateResolver(resolver);
    return engine;

}
 
開發者ID:mvc-spec,項目名稱:ozark,代碼行數:12,代碼來源:DefaultTemplateEngineProducer.java

示例9: templateResolver

import org.thymeleaf.templateresolver.ServletContextTemplateResolver; //導入依賴的package包/類
@Bean
public ServletContextTemplateResolver templateResolver() {
    ServletContextTemplateResolver resolver = new ServletContextTemplateResolver();
    resolver.setPrefix(PREFIX);
    resolver.setSuffix(SUFFIX);
    resolver.setTemplateMode(TEMPLATE_MODE);
    resolver.setOrder(1);
    resolver.setCacheable(false);
    return resolver;
}
 
開發者ID:macielbombonato,項目名稱:apolo,代碼行數:11,代碼來源:ThymeleafConfig.java

示例10: templateResolver

import org.thymeleaf.templateresolver.ServletContextTemplateResolver; //導入依賴的package包/類
@Bean
public ServletContextTemplateResolver templateResolver(ServletContext servletContext) {
    ServletContextTemplateResolver resolver = new ServletContextTemplateResolver(servletContext);
    resolver.setPrefix(VIEWS);
    resolver.setSuffix(".html");
    resolver.setTemplateMode("HTML");
    resolver.setCharacterEncoding("UTF-8");
    resolver.setOrder(1);
    return resolver;
}
 
開發者ID:astrohome,項目名稱:photogallery,代碼行數:11,代碼來源:WebMvcConfig.java

示例11: templateEngine

import org.thymeleaf.templateresolver.ServletContextTemplateResolver; //導入依賴的package包/類
@Bean
    public SpringTemplateEngine templateEngine(ServletContextTemplateResolver templateResolver) {
        Set<IDialect> dialects = new HashSet<>();
        dialects.add(new MyDialect());

        SpringTemplateEngine engine = new SpringTemplateEngine();
        engine.setTemplateResolver(templateResolver);
        engine.setAdditionalDialects(dialects);
//        engine.addDialect(new SpringSecurityDialect());
        return engine;
    }
 
開發者ID:astrohome,項目名稱:photogallery,代碼行數:12,代碼來源:WebMvcConfig.java

示例12: defaultTemplateResolver

import org.thymeleaf.templateresolver.ServletContextTemplateResolver; //導入依賴的package包/類
@Bean
public TemplateResolver defaultTemplateResolver() {
    ServletContextTemplateResolver templateResolver = new ServletContextTemplateResolver();
    templateResolver.setPrefix("/WEB-INF/views/thymeleaf/");
    templateResolver.setSuffix(".html");
    templateResolver.setTemplateMode("HTML5");
    templateResolver.setCacheable(false); // for development mode.

    return templateResolver;
}
 
開發者ID:gustavoorsi,項目名稱:searchahouse.com,代碼行數:11,代碼來源:ThymeleafConfiguration.java

示例13: thymeleafViewResolver

import org.thymeleaf.templateresolver.ServletContextTemplateResolver; //導入依賴的package包/類
@Bean
public ThymeleafViewResolver thymeleafViewResolver(WebApplicationContext wac) {
    ThymeleafViewResolver resolver = new ThymeleafViewResolver();
    SpringTemplateEngine templateEngine = new SpringTemplateEngine();
    ServletContextTemplateResolver templateResolver = new ServletContextTemplateResolver();
    templateResolver.setPrefix("/WEB-INF/templates/");
    templateResolver.setSuffix(".html");
    templateResolver.setTemplateMode("HTML5");
    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;
}
 
開發者ID:acesinc,項目名稱:convergent-ui,代碼行數:29,代碼來源:MVCConfig.java

示例14: webTemplateResolver

import org.thymeleaf.templateresolver.ServletContextTemplateResolver; //導入依賴的package包/類
@Bean
public TemplateResolver webTemplateResolver() {
	TemplateResolver templateResolver = new ServletContextTemplateResolver();
	templateResolver.setPrefix(TEMPLATE_RESOLVER_PREFIX);
	templateResolver.setSuffix(TEMPLATE_RESOLVER_SUFFIX);
	templateResolver.setTemplateMode(TEMPLATE_RESOLVER_TEMPLATE_MODE);
	templateResolver.setCharacterEncoding(TEMPLATE_RESOLVER_CHAR_ENCODING);
	templateResolver.setCacheable(false);
	return templateResolver;
}
 
開發者ID:gsag,項目名稱:spring-mvc-seed,代碼行數:11,代碼來源:WebMvcConfiguration.java

示例15: init

import org.thymeleaf.templateresolver.ServletContextTemplateResolver; //導入依賴的package包/類
@PostConstruct
public void init() {
    ServletContextTemplateResolver resolver = new ServletContextTemplateResolver();
    resolver.setTemplateMode("HTML5");
    resolver.setSuffix(".html");
    resolver.setPrefix("/WEB-INF/templates");

    templateEngine = new TemplateEngine();
    templateEngine.setTemplateResolver(resolver);
}
 
開發者ID:koenighotze,項目名稱:Hotel-Reservation-Tool,代碼行數:11,代碼來源:ThymeleafIntegration.java


注:本文中的org.thymeleaf.templateresolver.ServletContextTemplateResolver類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。