本文整理汇总了Java中groovy.text.markup.MarkupTemplateEngine.TemplateResource方法的典型用法代码示例。如果您正苦于以下问题:Java MarkupTemplateEngine.TemplateResource方法的具体用法?Java MarkupTemplateEngine.TemplateResource怎么用?Java MarkupTemplateEngine.TemplateResource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类groovy.text.markup.MarkupTemplateEngine
的用法示例。
在下文中一共展示了MarkupTemplateEngine.TemplateResource方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resolveTemplate
import groovy.text.markup.MarkupTemplateEngine; //导入方法依赖的package包/类
/**
* Resolve a template from the given template path.
* <p>The default implementation uses the Locale associated with the current request,
* as obtained through {@link org.springframework.context.i18n.LocaleContextHolder LocaleContextHolder},
* to find the template file. Effectively the locale configured at the engine level is ignored.
* @see LocaleContextHolder
* @see #setLocale
*/
protected URL resolveTemplate(ClassLoader classLoader, String templatePath) throws IOException {
MarkupTemplateEngine.TemplateResource resource = MarkupTemplateEngine.TemplateResource.parse(templatePath);
Locale locale = LocaleContextHolder.getLocale();
URL url = classLoader.getResource(resource.withLocale(locale.toString().replace("-", "_")).toString());
if (url == null) {
url = classLoader.getResource(resource.withLocale(locale.getLanguage()).toString());
}
if (url == null) {
url = classLoader.getResource(resource.withLocale(null).toString());
}
if (url == null) {
throw new IOException("Unable to load template:" + templatePath);
}
return url;
}
示例2: resolveTemplate
import groovy.text.markup.MarkupTemplateEngine; //导入方法依赖的package包/类
@Override
public URL resolveTemplate(final String templatePath) throws IOException {
MarkupTemplateEngine.TemplateResource templateResource = MarkupTemplateEngine.TemplateResource
.parse(templatePath);
URL resource = this.templateClassLoader.getResource(templateResource
.withLocale(LocaleContextHolder.getLocale().toString().replace("-", "_"))
.toString());
if (resource == null) {
// no resource found with the default locale, try without any locale
resource = this.templateClassLoader
.getResource(templateResource.withLocale(null).toString());
}
if (resource == null) {
throw new IOException("Unable to load template:" + templatePath);
}
return resource;
}
示例3: createTemplatePath
import groovy.text.markup.MarkupTemplateEngine; //导入方法依赖的package包/类
private String createTemplatePath(final String viewName, final Locale locale) {
MarkupTemplateEngine.TemplateResource resource = MarkupTemplateEngine.TemplateResource.parse(viewName);
resource.withLocale(locale.toString().replace("-", "_"));
return resource.toString();
}