本文整理汇总了Java中org.springframework.web.servlet.view.freemarker.FreeMarkerConfig类的典型用法代码示例。如果您正苦于以下问题:Java FreeMarkerConfig类的具体用法?Java FreeMarkerConfig怎么用?Java FreeMarkerConfig使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FreeMarkerConfig类属于org.springframework.web.servlet.view.freemarker包,在下文中一共展示了FreeMarkerConfig类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: freeMarkerConfigurer
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfig; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean({FreeMarkerConfig.class, FreeMarkerViewResolver.class})
public FreeMarkerConfigurer freeMarkerConfigurer() {
PluginFreeMarkerConfigurer configurer = new PluginFreeMarkerConfigurer();
applyProperties(configurer);
String[] paths = this.properties.getTemplateLoaderPath();
// paths = ArrayUtils.add(paths, WEBFTLS_PATH);
configurer.setTemplateLoaderPaths(paths);
List<WithAnnotationBeanData<FreeMarkerViewTools>> tools = SpringUtils.getBeansWithAnnotation(applicationContext, FreeMarkerViewTools.class);
tools.forEach(t->{
String name = t.getAnnotation().value();
if(StringUtils.isBlank(name)){
name = t.getBean().getClass().getSimpleName();
}
configurer.setFreemarkerVariable(name, t.getBean());
logger.info("registered FreeMarkerViewTools : {}", name);
});
return configurer;
}
示例2: getFreeMarkerConfig
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfig; //导入依赖的package包/类
public static FreeMarkerConfig getFreeMarkerConfig(ApplicationContext applicationContext, String templateLoaderPath) {
if (configurer != null) {
return configurer;
}
configurer = getFreeMarkerConfigurer(applicationContext, templateLoaderPath);
return configurer;
}
示例3: contextInitialized
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfig; //导入依赖的package包/类
public void contextInitialized(ServletContextEvent sc) {
logger.info("[5i net registry listener starting...]");
ApplicationContext context = WebApplicationContextUtils.getRequiredWebApplicationContext(sc.getServletContext());
// 资源实例
ResourceBundle resource = ResourceBundle.getInstance();
resource.setFreemarkerConfig((FreeMarkerConfig) context.getBean("freemarkerConfig"));
logger.info("[5i net registry listener finished...]");
}
示例4: freeMarkerConfigurer
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfig; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean(FreeMarkerConfig.class)
public FreeMarkerConfigurer freeMarkerConfigurer() {
FreeMarkerConfigurer configurer = new FreeMarkerConfigurer();
applyProperties(configurer);
return configurer;
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:8,代码来源:FreeMarkerAutoConfiguration.java
示例5: autodetectConfiguration
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfig; //导入依赖的package包/类
/**
* 自动检测FreeMarkerConfig
*
* @return
* @throws BeansException
*/
protected FreeMarkerConfig autodetectConfiguration() throws BeansException {
try {
return (FreeMarkerConfig) BeanFactoryUtils
.beanOfTypeIncludingAncestors(getApplicationContext(),
FreeMarkerConfig.class, true, false);
} catch (NoSuchBeanDefinitionException ex) {
throw new ApplicationContextException(
"Must define a single FreeMarkerConfig bean in this web application context "
+ "(may be inherited): FreeMarkerConfigurer is the usual implementation. "
+ "This bean may be given any name.", ex);
}
}
示例6: autodetectConfiguration
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfig; //导入依赖的package包/类
@Override
protected FreeMarkerConfig autodetectConfiguration() throws BeansException {
try {
return (FreeMarkerConfig) BeanFactoryUtils.beanOfType(
getApplicationContext(), FreeMarkerConfig.class, true,
false);
} catch (NoSuchBeanDefinitionException ex) {
throw new ApplicationContextException(
"Must define a single FreeMarkerConfig bean in this web application context "
+ "(may be inherited): FreeMarkerConfigurer is the usual implementation. "
+ "This bean may be given any name.", ex);
}
}
示例7: freemarkerConfig
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfig; //导入依赖的package包/类
@Bean
public FreeMarkerConfigurer freemarkerConfig() throws IOException, TemplateException {
FreeMarkerConfigurer freeMarkerConfigurer = new FreeMarkerConfigurer();
freeMarkerConfigurer.setConfiguration(new freemarker.template.Configuration(freemarker.template.Configuration.VERSION_2_3_22) {{
setTemplateLoader(new MultiTemplateLoader(
new TemplateLoader[]{
new ClassTemplateLoader(FreeMarkerConfig.class, "/")
}
));
setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
setWhitespaceStripping(true);
}});
return freeMarkerConfigurer;
}
示例8: autodetectConfiguration
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfig; //导入依赖的package包/类
@Override
protected FreeMarkerConfig autodetectConfiguration() throws BeansException {
System.out.println("autodetectConfiguration:");
String templateLoaderPath = "";
return FreeMarkerUtil.getFreeMarkerConfig(super.getApplicationContext(), templateLoaderPath);
}
示例9: getFreemarkerConfig
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfig; //导入依赖的package包/类
public FreeMarkerConfig getFreemarkerConfig() {
return freemarkerConfig;
}
示例10: setFreemarkerConfig
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfig; //导入依赖的package包/类
public void setFreemarkerConfig(FreeMarkerConfig freemarkerConfig) {
this.freemarkerConfig = freemarkerConfig;
}
示例11: freeMarkerConfiguration
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfig; //导入依赖的package包/类
@Bean
public freemarker.template.Configuration freeMarkerConfiguration(
FreeMarkerConfig configurer) {
return configurer.getConfiguration();
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:6,代码来源:FreeMarkerAutoConfiguration.java
示例12: initApplicationContext
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfig; //导入依赖的package包/类
/**
* Invoked on startup. Looks for a single FreeMarkerConfig bean to find the
* relevant Configuration for this factory.
* <p>
* Checks that the template for the default Locale can be found: FreeMarker
* will check non-Locale-specific templates if a locale-specific one is not
* found.
*
* @see freemarker.cache.TemplateCache#getTemplate
*/
protected void initApplicationContext() throws BeansException {
super.initApplicationContext();
if (getConfiguration() == null) {
FreeMarkerConfig config = autodetectConfiguration();
setConfiguration(config.getConfiguration());
}
checkTemplate();
}