Spring集成JSF的最简单方式
时间:2011-02-13
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>
|