本文整理匯總了Java中org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer.setTemplateLoaderPaths方法的典型用法代碼示例。如果您正苦於以下問題:Java FreeMarkerConfigurer.setTemplateLoaderPaths方法的具體用法?Java FreeMarkerConfigurer.setTemplateLoaderPaths怎麽用?Java FreeMarkerConfigurer.setTemplateLoaderPaths使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer
的用法示例。
在下文中一共展示了FreeMarkerConfigurer.setTemplateLoaderPaths方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: freemarkerConfig
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer; //導入方法依賴的package包/類
@Bean
public FreeMarkerConfigurer freemarkerConfig() {
FreeMarkerConfigurer config = new FreeMarkerConfigurer();
config.setDefaultEncoding("UTF-8");
String[] paths = {"/WEB-INF/freemarker/", "classpath:/freemarker/"};
config.setTemplateLoaderPaths(paths);
Map<String, Object> variables = Maps.newHashMap();
variables.put("xml_escape", fmXmlEscape());
config.setFreemarkerVariables(variables);
return config;
}
示例2: freeMarkerConfigurer
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer; //導入方法依賴的package包/類
/**
* Overrides Spring Boot's {@link FreeMarkerAutoConfiguration} to prefer using a
* {@link SpringTemplateLoader} instead of the file system. This corrects an issue
* where Spring Boot may use an empty 'templates' file resource to resolve templates
* instead of the packaged Hystrix classpath templates.
* @return FreeMarker configuration
*/
@Bean
public FreeMarkerConfigurer freeMarkerConfigurer() {
FreeMarkerConfigurer configurer = new FreeMarkerConfigurer();
configurer.setTemplateLoaderPaths(DEFAULT_TEMPLATE_LOADER_PATH);
configurer.setDefaultEncoding(DEFAULT_CHARSET);
configurer.setPreferFileSystemAccess(false);
return configurer;
}