今天我使用Spring 和 JSF集成是遇到了一个问题:FacesContextUtils.getWebApplicationContext(FacesContext.getCurrentInstance())
得到的ApplicationContext 总是为 null ,几经周折,在一家外文网上找到了答案特贴出来与大家分享(目前我很菜的):
需在JSF的faces-config.xml中加入这样一段:
<application>
<variable-resolver>
org.springframework.web.jsf.DelegatingVariableResolver
</variable-resolver>
</application>
这段话的关键是:DelegatingVariableResolver 是spring中 用JSF的一个变量解释器,也就是spring在faces-config.xml
中的一个托管Bean 。
加了这段话就解决了上述函数为空的情况。。
令付参考外文网址:http://www.kecteck.com/blog/?p=148点击打开链接