类 GroovyMarkupConfigurer

  • 所有已实现的接口:
    Aware, InitializingBean, ApplicationContextAware, GroovyMarkupConfig

    public class GroovyMarkupConfigurer
    extends groovy.text.markup.TemplateConfiguration
    implements GroovyMarkupConfig, ApplicationContextAware, InitializingBean
    An extension of Groovy's TemplateConfiguration and an implementation of Spring MVC's GroovyMarkupConfig for creating a MarkupTemplateEngine for use in a web application. The most basic way to configure this class is to set the "resourceLoaderPath". For example:
    
     // Add the following to an @Configuration class
    
     @Bean
     public GroovyMarkupConfig groovyMarkupConfigurer() {
         GroovyMarkupConfigurer configurer = new GroovyMarkupConfigurer();
         configurer.setResourceLoaderPath("classpath:/WEB-INF/groovymarkup/");
         return configurer;
     }
     
    By default this bean will create a MarkupTemplateEngine with:
    • a parent ClassLoader for loading Groovy templates with their references
    • the default configuration in the base class TemplateConfiguration
    • a TemplateResolver for resolving template files
    You can provide the MarkupTemplateEngine instance directly to this bean in which case all other properties will not be effectively ignored.

    This bean must be included in the application context of any application using the Spring MVC GroovyMarkupView for rendering. It exists purely for the purpose of configuring Groovy's Markup templates. It is not meant to be referenced by application components directly. It implements GroovyMarkupConfig to be found by GroovyMarkupView without depending on a bean name. Each DispatcherServlet can define its own GroovyMarkupConfigurer if desired.

    Note that resource caching is enabled by default in MarkupTemplateEngine. Use the TemplateConfiguration.setCacheTemplates(boolean) to configure that as necessary.

    Spring's Groovy Markup template support requires Groovy 2.3.1 or higher.

    从以下版本开始:
    4.1
    作者:
    Brian Clozel, Rossen Stoyanchev
    另请参阅:
    GroovyMarkupView, Groovy Markup Template engine documentation