public static FreeMarkerConfigurer freeMarkerConfigurer; //Freemarker
public FreeMarkerConfigurer getFreeMarkerConfigurer() {
return StaticResourceBiz.freeMarkerConfigurer;
}
@Autowired //@Autowired写到的set方法上,set方法为非静态
public void setFreeMarkerConfigurer(
FreeMarkerConfigurer freeMarkerConfigurer) {
if(StaticResourceBiz.freeMarkerConfigurer == null){
StaticResourceBiz.freeMarkerConfigurer = freeMarkerConfigurer;
}
}
freemarker配置,与以上问题没关系
<!-- 配置freeMarker的模板路径 -->
<bean id="freemarkerConfig"
class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
<property name="freemarkerSettings" ref="freemarkerConfiguration" />
<property name="templateLoaderPaths">
<list>
<value>WEB-INF/templates/</value>
<value>classpath:/templates/</value>
</list>
</property>
<property name="freemarkerVariables">
<map>
<entry key="xml_escape" value-ref="fmXmlEscape" />
<entry key="extends" value-ref="extendsDirective"></entry>
<entry key="override" value-ref="overrideDirective"></entry>
<entry key="block" value-ref="blockDirective"></entry>
<entry key="super" value-ref="superDirective"></entry>
<!-- 自定义tag -->
<entry key="dictTag" value-ref="dictTagDirective"></entry>
</map>
</property>
<property name="preferFileSystemAccess" value="false" />
</bean>