2013-09-27 106 views
0

我有2个名为spring-context.xml和spring-view.xml的XML文件。 spring-context.xml在web.xml文件中的上下文上下文参数标签内声明。自定义PropertyPlaceholderConfigurer不工作

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 bean,${message}已解决并且工作得很好。

这里有什么问题。

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

+0

@Ben:谢谢你编辑我的问题。 – JackVimal

+0

其他人[建议它](http://stackoverflow.com/review/suggested-edits/3015563)杰克,我做了更多的编辑。 – Ben

回答

0

否... Bean(工厂)后处理程序仅在其加载的ApplicationContext中/上运行。根上下文中的Bean(Factory)PostProcessors不在子上下文中操作/修改Bean,反之亦然。

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