[英]Make custom TemplateMethodModels available in Freemarker for Spring Boot 2
我在Spring Boot 2项目中为Freemarker模板创建了freemarker.template.TemplateMethodModelEx
几种实现。 当前,为了在我的视图中使用它们,我需要将它们添加到每个WebMVC控制器的模型中(用Freemarker术语表示为“哈希”)。
我希望有一种方法可以使它们在项目的每个视图中可用,而不必在每个控制器中扩展模型。
FreeMarker具有通过Configuration.setSharedVariable(String, Object)
API在Configuration
单例级别上添加顶级变量的功能。 显然,Spring FreeMarkerConfigurationFactory
在属性名称“ freemarkerVariables”下公开了它: https : //docs.spring.io/spring/docs/current/javadoc-api/org/springframework/ui/freemarker/FreeMarkerConfigurationFactory.html#setFreemarkerVariables-java。 util.Map-
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.