本文整理了Java中freemarker.cache.WebappTemplateLoader.<init>()
方法的一些代码示例,展示了WebappTemplateLoader.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebappTemplateLoader.<init>()
方法的具体详情如下:
包路径:freemarker.cache.WebappTemplateLoader
类名称:WebappTemplateLoader
方法名:<init>
[英]Creates a resource template cache that will use the specified servlet context to load the resources. It will use the base path of "/"
meaning templates will be resolved relative to the servlet context root location.
[中]创建一个资源模板缓存,该缓存将使用指定的servlet上下文加载资源。它将使用"/"
的基本路径,这意味着模板将相对于servlet上下文根位置进行解析。
代码示例来源:origin: jersey/jersey
public FreemarkerDefaultConfigurationFactory(ServletContext servletContext) {
super();
// Create different loaders.
final List<TemplateLoader> loaders = new ArrayList<>();
if (servletContext != null) {
loaders.add(new WebappTemplateLoader(servletContext));
}
loaders.add(new ClassTemplateLoader(FreemarkerDefaultConfigurationFactory.class, "/"));
try {
loaders.add(new FileTemplateLoader(new File("/")));
} catch (IOException e) {
// NOOP
}
// Create Base configuration.
configuration = new Configuration();
configuration.setTemplateLoader(new MultiTemplateLoader(loaders.toArray(new TemplateLoader[loaders.size()])));
}
代码示例来源:origin: org.freemarker/freemarker
throw new TemplatePathParsingException("Template paths starting with \"{\" are reseved for future purposes");
} else {
templateLoader = new WebappTemplateLoader(srvCtx, pureTemplatePath);
代码示例来源:origin: vivo-project/Vitro
private Template loadFreemarkerTemplate() throws IOException {
Configuration cfg = new Configuration();
cfg.setTemplateLoader(new WebappTemplateLoader(ctx));
return cfg.getTemplate(TEMPLATE_PATH);
}
代码示例来源:origin: org.glassfish.jersey.ext/jersey-mvc-freemarker
public FreemarkerDefaultConfigurationFactory(ServletContext servletContext) {
super();
// Create different loaders.
final List<TemplateLoader> loaders = new ArrayList<>();
if (servletContext != null) {
loaders.add(new WebappTemplateLoader(servletContext));
}
loaders.add(new ClassTemplateLoader(FreemarkerDefaultConfigurationFactory.class, "/"));
try {
loaders.add(new FileTemplateLoader(new File("/")));
} catch (IOException e) {
// NOOP
}
// Create Base configuration.
configuration = new Configuration();
configuration.setTemplateLoader(new MultiTemplateLoader(loaders.toArray(new TemplateLoader[loaders.size()])));
}
代码示例来源:origin: info.magnolia.core/magnolia-freemarker-support
@Override
protected TemplateLoader newDelegate() {
final WebContext webCtx = MgnlContext.getWebContextOrNull();
if (webCtx != null) {
final ServletContext sc = webCtx.getServletContext();
if (sc != null) {
return new WebappTemplateLoader(sc, "");
}
}
return null;
}
}
代码示例来源:origin: org.apache.drill.exec/drill-java-exec
/**
* Creates freemarker configuration settings,
* default output format to trigger auto-escaping policy
* and template loaders.
*
* @param servletContext servlet context
* @return freemarker configuration settings
*/
private Configuration getFreemarkerConfiguration(ServletContext servletContext) {
Configuration configuration = new Configuration(Configuration.VERSION_2_3_26);
configuration.setOutputFormat(HTMLOutputFormat.INSTANCE);
List<TemplateLoader> loaders = new ArrayList<>();
loaders.add(new WebappTemplateLoader(servletContext));
loaders.add(new ClassTemplateLoader(DrillRestServer.class, "/"));
try {
loaders.add(new FileTemplateLoader(new File("/")));
} catch (IOException e) {
logger.error("Could not set up file template loader.", e);
}
configuration.setTemplateLoader(new MultiTemplateLoader(loaders.toArray(new TemplateLoader[loaders.size()])));
return configuration;
}
代码示例来源:origin: org.freemarker/com.springsource.freemarker
/**
* Create the template loader. The default implementation will create a
* {@link ClassTemplateLoader} if the template path starts with "class://",
* a {@link FileTemplateLoader} if the template path starts with "file://",
* and a {@link WebappTemplateLoader} otherwise.
* @param templatePath the template path to create a loader for
* @return a newly created template loader
* @throws IOException
*/
protected TemplateLoader createTemplateLoader(String templatePath) throws IOException
{
if (templatePath.startsWith("class://")) {
// substring(7) is intentional as we "reuse" the last slash
return new ClassTemplateLoader(getClass(), templatePath.substring(7));
} else {
if (templatePath.startsWith("file://")) {
templatePath = templatePath.substring(7);
return new FileTemplateLoader(new File(templatePath));
} else {
return new WebappTemplateLoader(this.getServletContext(), templatePath);
}
}
}
代码示例来源:origin: com.opensymphony/webwork
new MultiTemplateLoader(new TemplateLoader[]{
templatePathLoader,
new WebappTemplateLoader(servletContext),
new WebWorkClassTemplateLoader()
})
: new MultiTemplateLoader(new TemplateLoader[]{
new WebappTemplateLoader(servletContext),
new WebWorkClassTemplateLoader()
});
代码示例来源:origin: com.netflix.pytheas/pytheas-core
new MultiTemplateLoader(
new TemplateLoader[]{
new WebappTemplateLoader( context, ROOT_PATH ),
new ClassTemplateLoader( getClass(), "/"),
new URLTemplateLoader() {
代码示例来源:origin: org.freemarker/freemarker-gae
throw new TemplatePathParsingException("Template paths starting with \"{\" are reseved for future purposes");
} else {
templateLoader = new WebappTemplateLoader(srvCtx, pureTemplatePath);
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.freemarker
throw new TemplatePathParsingException("Template paths starting with \"{\" are reseved for future purposes");
} else {
templateLoader = new WebappTemplateLoader(srvCtx, pureTemplatePath);
内容来源于网络,如有侵权,请联系作者删除!