我正在使用JSF2.0并且正在考虑做一些spring security 3.2。这要求我将一些豆DI从面部移动到Spring 3.2。
这是我之前在faces-config.xml中所拥有的:
<managed-bean>
<managed-bean-name>site</managed-bean-name>
<managed-bean-class>mypackage.Site</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
<managed-property>
<property-name>hostName</property-name>
<value>#{header['host']}</value>
</managed-property>
</managed-bean>
<managed-bean>
<managed-bean-name>LoginPasswordBean</managed-bean-name>
<managed-bean-class>mypackage.LoginPasswordBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
<managed-property>
<property-name>site</property-name>
<value>#{site}</value>
</managed-property>
</managed-bean>
我用这个更新了faces-config:
<application>
<el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
</application>
用这个更新web.xml:
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
这就是我现在在applicationContext.xml文件中尝试但不工作的内容:
<beans:bean id="site"
class="mypackage.Site" scope="request">
<beans:property name="hostName" ref="header['host']"></beans:property>
</beans:bean>
<beans:bean id="LoginPasswordBean" name="LoginPasswordBean"
class="mypackage.LoginPasswordBean"
scope="prototype">
<beans:property name="site" ref="site"></beans:property>
</beans:bean>
有关如何定义站点对象以访问请求标头的任何想法。 我得到的错误是:
无法解析对bean&#39;标题的引用[&#39; host&#39;]&#39;而 设置bean属性&#39; hostName&#39;;
我也试过这些:
header['host']
request.header['host']
#{header['host']}
#{request.header['host']}