类 GroovyMarkupConfigurer
- 所有已实现的接口:
cn.taketoday.beans.factory.Aware,cn.taketoday.beans.factory.InitializingBean,cn.taketoday.context.ApplicationContextAware,GroovyMarkupConfig
TemplateConfiguration and
an implementation of Framework 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
TemplateResolverfor resolving template files
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 Framework 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.
Framework's Groovy Markup template support requires Groovy 2.3.1 or higher.
- 从以下版本开始:
- 4.0
- 作者:
- Brian Clozel, Rossen Stoyanchev
- 另请参阅:
-
嵌套类概要
嵌套类修饰符和类型类说明private classCustomtemplate resolverthat simply delegates toresolveTemplate(ClassLoader, String).. -
字段概要
字段修饰符和类型字段说明private cn.taketoday.context.ApplicationContextprivate Stringprivate groovy.text.markup.MarkupTemplateEngine -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明voidprotected ClassLoaderCreate a parent ClassLoader for Groovy to use as parent ClassLoader when loading and compiling templates.protected groovy.text.markup.MarkupTemplateEngineprotected cn.taketoday.context.ApplicationContextgroovy.text.markup.MarkupTemplateEngineReturn the GroovyMarkupTemplateEnginefor the current web application context.protected URLresolveTemplate(ClassLoader classLoader, String templatePath) Resolve a template from the given template path.voidsetApplicationContext(cn.taketoday.context.ApplicationContext applicationContext) voidThis method should not be used, since the considered Locale for resolving templates is the Locale for the current HTTP request.voidsetResourceLoaderPath(String resourceLoaderPath) Set the Groovy Markup Template resource loader path(s) via a Framework resource location.voidsetTemplateEngine(groovy.text.markup.MarkupTemplateEngine templateEngine) Set a pre-configured MarkupTemplateEngine to use for the Groovy Markup Template web configuration.从类继承的方法 groovy.text.markup.TemplateConfiguration
getAutoIndentString, getBaseTemplateClass, getDeclarationEncoding, getLocale, getNewLineString, isAutoEscape, isAutoIndent, isAutoNewLine, isCacheTemplates, isExpandEmptyElements, isUseDoubleQuotes, setAutoEscape, setAutoIndent, setAutoIndentString, setAutoNewLine, setBaseTemplateClass, setCacheTemplates, setDeclarationEncoding, setExpandEmptyElements, setNewLineString, setUseDoubleQuotes
-
字段详细资料
-
resourceLoaderPath
-
templateEngine
@Nullable private groovy.text.markup.MarkupTemplateEngine templateEngine -
applicationContext
@Nullable private cn.taketoday.context.ApplicationContext applicationContext
-
-
构造器详细资料
-
GroovyMarkupConfigurer
public GroovyMarkupConfigurer()
-
-
方法详细资料
-
setResourceLoaderPath
Set the Groovy Markup Template resource loader path(s) via a Framework resource location. Accepts multiple locations as a comma-separated list of paths. Standard URLs like "file:" and "classpath:" and pseudo URLs are supported as understood by Framework'sResourceLoader. Relative paths are allowed when running in an ApplicationContext. -
getResourceLoaderPath
-
setTemplateEngine
public void setTemplateEngine(groovy.text.markup.MarkupTemplateEngine templateEngine) Set a pre-configured MarkupTemplateEngine to use for the Groovy Markup Template web configuration.Note that this engine instance has to be manually configured, since all other bean properties of this configurer will be ignored.
-
getTemplateEngine
public groovy.text.markup.MarkupTemplateEngine getTemplateEngine()从接口复制的说明:GroovyMarkupConfigReturn the GroovyMarkupTemplateEnginefor the current web application context. May be unique to one servlet, or shared in the root context.- 指定者:
getTemplateEngine在接口中GroovyMarkupConfig- 返回:
- the Groovy MarkupTemplateEngine engine
-
setApplicationContext
public void setApplicationContext(cn.taketoday.context.ApplicationContext applicationContext) - 指定者:
setApplicationContext在接口中cn.taketoday.context.ApplicationContextAware
-
getApplicationContext
protected cn.taketoday.context.ApplicationContext getApplicationContext() -
setLocale
This method should not be used, since the considered Locale for resolving templates is the Locale for the current HTTP request.- 覆盖:
setLocale在类中groovy.text.markup.TemplateConfiguration
-
afterPropertiesSet
- 指定者:
afterPropertiesSet在接口中cn.taketoday.beans.factory.InitializingBean- 抛出:
Exception
-
createTemplateEngine
- 抛出:
IOException
-
createTemplateClassLoader
Create a parent ClassLoader for Groovy to use as parent ClassLoader when loading and compiling templates.- 抛出:
IOException
-
resolveTemplate
Resolve a template from the given template path.The default implementation uses the Locale associated with the current request, as obtained through
LocaleContextHolder, to find the template file. Effectively the locale configured at the engine level is ignored.- 抛出:
IOException- 另请参阅:
-
LocaleContextHoldersetLocale(java.util.Locale)
-