Is there a way to set message headers from a bean?

谁说胖子不能爱 提交于 2019-12-03 13:18:55

Certainly! One of the options available is

.setHeader("headerName").method(beanInstance, "methodToGetHeaderValue")

Using this approach, the method (say, methodToGetHeaderValue) on the provided bean instance will return a value, and that will become the value of the header.

There are a number of options available. You can call it with a bean instance, a bean class (like in your example), or even a bean name, all with or without a method name.

In Spring XML DSL, it would be something like

 <setHeader headerName="headerName">
      <method bean="mybean" method="mymethod" />                
</setHeader>
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!