context:property-placeholder标签是将.properties文件加载到web容器里,然后再bean中可以使用${}获取properties文件中的值,例如:properties文件中设置了template.suffix=.ftl,那么在springmvc.xml文件中
<bean id="viewResolver" class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
<property name="suffix" value="${template.suffix}"/><property name="contentType" value="text/html; charset=utf-8"></property>
</bean>
使用
context:properties-placeholder有ignore-resource-not-found和ignore-unresolvable属性,ignore-unresolvable表示忽略解析不到的属性,ignore-resource-not-found表示忽略找不到属性的文件,如果不忽略,则抛出异常
本文介绍了如何在Spring MVC框架中使用property-placeholder标签来加载.properties配置文件,并在Bean定义中通过${}
1403

被折叠的 条评论
为什么被折叠?



