本文整理汇总了Java中org.springframework.ui.freemarker.SpringTemplateLoader类的典型用法代码示例。如果您正苦于以下问题:Java SpringTemplateLoader类的具体用法?Java SpringTemplateLoader怎么用?Java SpringTemplateLoader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SpringTemplateLoader类属于org.springframework.ui.freemarker包,在下文中一共展示了SpringTemplateLoader类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getTemplateLoaderForPath
import org.springframework.ui.freemarker.SpringTemplateLoader; //导入依赖的package包/类
public static TemplateLoader getTemplateLoaderForPath(ResourceLoader resourceLoader, String templateLoaderPath) {
try {
Resource path = resourceLoader.getResource(templateLoaderPath);
File file = path.getFile(); // will fail if not resolvable in the file system
if (logger.isDebugEnabled()) {
logger.debug(
"Template loader path [" + path + "] resolved to file path [" + file.getAbsolutePath() + "]");
}
return new FileTemplateLoader(file);
}
catch (IOException ex) {
if (logger.isDebugEnabled()) {
logger.debug("Cannot resolve template loader path [" + templateLoaderPath +
"] to [java.io.File]: using SpringTemplateLoader as fallback", ex);
}
return new SpringTemplateLoader(resourceLoader, templateLoaderPath);
}
}
开发者ID:wayshall,项目名称:onetwo,代码行数:20,代码来源:FtlUtils.java
示例2: freeMarkerConfigurationFactoryBeanWithResourceLoaderPath
import org.springframework.ui.freemarker.SpringTemplateLoader; //导入依赖的package包/类
@Test
public void freeMarkerConfigurationFactoryBeanWithResourceLoaderPath() throws Exception {
FreeMarkerConfigurationFactoryBean fcfb = new FreeMarkerConfigurationFactoryBean();
fcfb.setTemplateLoaderPath("file:/mydir");
fcfb.afterPropertiesSet();
Configuration cfg = fcfb.getObject();
assertTrue(cfg.getTemplateLoader() instanceof SpringTemplateLoader);
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:9,代码来源:FreeMarkerConfigurerTests.java
示例3: freeMarkerConfigurationAsBean
import org.springframework.ui.freemarker.SpringTemplateLoader; //导入依赖的package包/类
@Test // SPR-12448
public void freeMarkerConfigurationAsBean() {
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
RootBeanDefinition loaderDef = new RootBeanDefinition(SpringTemplateLoader.class);
loaderDef.getConstructorArgumentValues().addGenericArgumentValue(new DefaultResourceLoader());
loaderDef.getConstructorArgumentValues().addGenericArgumentValue("/freemarker");
RootBeanDefinition configDef = new RootBeanDefinition(Configuration.class);
configDef.getPropertyValues().add("templateLoader", loaderDef);
beanFactory.registerBeanDefinition("freeMarkerConfig", configDef);
beanFactory.getBean(Configuration.class);
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:12,代码来源:FreeMarkerConfigurerTests.java
示例4: render
import org.springframework.ui.freemarker.SpringTemplateLoader; //导入依赖的package包/类
@Override
public void render(Map<String, ?> model, HttpServletRequest request, HttpServletResponse response) throws Exception {
Configuration config = configurer.getConfiguration();
// config.setTemplateLoader(new ClassTemplateLoader(this.getClass(), folder));
config.setTemplateLoader(new SpringTemplateLoader(new DefaultResourceLoader(), folder));
// return config.getTemplate(name, "UTF-8");
Template template = config.getTemplate(viewName + ".ftl", "UTF-8");
response.setContentType(getContentType());
Writer out = response.getWriter();
template.process(model, out);
}
开发者ID:tanhaichao,项目名称:leopard,代码行数:13,代码来源:ClassPathModelAndView.java
示例5: getTemplateLoader
import org.springframework.ui.freemarker.SpringTemplateLoader; //导入依赖的package包/类
private TemplateLoader getTemplateLoader(final String templatePath) {
try {
// Classpath loading
if (templatePath.startsWith("classpath:")) {
final Resource path = resourceLoader.getResource(templatePath);
return new FileTemplateLoader(path.getFile());
}
// Filebase loading
return new FileTemplateLoader(new File(templatePath));
} catch (final IOException e) {
LOGGER.debug("Error while getting templateLoader, will fallback to SpringTemplateLoader.", e);
return new SpringTemplateLoader(resourceLoader, templatePath);
}
}
开发者ID:JanLoebel,项目名称:uaa-service,代码行数:16,代码来源:TemplateConfig.java
示例6: testFreeMarkerConfigurationFactoryBeanWithResourceLoaderPath
import org.springframework.ui.freemarker.SpringTemplateLoader; //导入依赖的package包/类
public void testFreeMarkerConfigurationFactoryBeanWithResourceLoaderPath() throws Exception {
FreeMarkerConfigurationFactoryBean fcfb = new FreeMarkerConfigurationFactoryBean();
fcfb.setTemplateLoaderPath("file:/mydir");
fcfb.afterPropertiesSet();
Configuration cfg = fcfb.getObject();
assertTrue(cfg.getTemplateLoader() instanceof SpringTemplateLoader);
}
开发者ID:deathspeeder,项目名称:class-guard,代码行数:8,代码来源:FreeMarkerConfigurerTests.java
示例7: freeMarkerConfig
import org.springframework.ui.freemarker.SpringTemplateLoader; //导入依赖的package包/类
@Bean
public FreeMarkerConfigurer freeMarkerConfig(ApplicationContext context) {
final FreeMarkerConfigurer freeMarkerConfigurer = new FreeMarkerConfigurer();
freeMarkerConfigurer.setPreTemplateLoaders(new SpringTemplateLoader(context, "/templates/"));
return freeMarkerConfigurer;
}
开发者ID:aliaksei-lithium,项目名称:spring5demo,代码行数:7,代码来源:ViewConfig.java
注:本文中的org.springframework.ui.freemarker.SpringTemplateLoader类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论