自定义PropertyPlaceholderConfigurer无法正常工作

时间:2013-09-27 08:23:20

标签: java spring spring-mvc

我有2个名为spring-context.xml和spring-view.xml的XML文件。 spring-context.xml在web.xml文件中的上下文context-param标记内声明。

spring-view.xml文件在web.xml中的spring servlet init-param中声明。我在spring-context.xml中声明了propertyConfigurer bean。 spring-view.xml中的以下代码

    <bean name="/home" class="com.company.web.controller.view.HomeViewController" >
    <property name="msg" value="${message}"></property>
    </bean>

${message}未解决。

如果我声明spring-view.xml propertyConfurer中的${message} bean已解决且工作正常。

这里可能有什么问题。

如果我在spring-context.xml中声明了一个propertyConfigurer bean。可以在spring-view.xml中访问这个propertyConfigurer bean吗?

1 个答案:

答案 0 :(得分:0)

否... Bean(工厂)PostProcessor仅在加载它们的ApplicationContext上运行。根上下文中的Bean(Factory)PostProcessors不在子上下文中操作/修改bean反之亦然。

您需要两次声明bean以在两个上下文中替换占位符。

相关问题