【发布时间】:2016-09-08 06:06:29
【问题描述】:
是否可以将 spring 集成标头的值设置为 bean 属性。
<int:header-enricher>
<int:header name="bId" expression="T(java.util.UUID).randomUUID()" />
</int:header-enricher>
现在在 bean 定义中
<bean id="" class="">
<property name="bId" value="#{headers['bId']}" />
</bean>
上面的代码不起作用。这会引发异常
Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 0): Property or field 'headers' cannot be found on object of type 'org.spri
ngframework.beans.factory.config.BeanExpressionContext' - maybe not public?
我尝试了以下方法,它们不起作用
<bean id="" class="">
<property name="bId" value="headers['bId']" />
</bean>
<bean id="" class="">
<property name="bId" ref="headers['bId']" />
</bean>
下面会很理想,但是这个expression 不可用
<bean id="" class="">
<property name="bId" expression="headers['bId']" />
</bean>
【问题讨论】: