今天我使用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點擊打開鏈接