`
happyqing
  • 浏览: 3194130 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

spring静态属性注入

阅读更多

 

	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>

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics