Spring集成JSF的最簡單方式是使用DelegatingVariableResolver類。在faces-config.xml中配置,示例如下:
<application>
<variable-resolver>org.springframework.web.jsf.
DelegatingVariableResolver</variable-resolver>
<locale-config>
<default-locale>zh_CN</default-locale>
<supported-locale>en</supported-locale>
<supported-locale>zh_CN</supported-locale>
</locale-config>
<message-bundle>messages</message-bundle>
</application>
直接通過managed-bean 的property屬性即可以得到spring中注入的bean:
<managed-bean>
<managed-bean-name>goodsController</managed-bean-name>
<managed-bean-class>web.jsf.GoodsController</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
<!-- inject service -->
<managed-property>
<property-name>goodsService</property-name>
<value>#{goodsService}</value> <!--注入Spring service -->
</managed-property>
</managed-bean>