我有带有路径和一个 pathVariables 的入站 channel 适配器,但现在我想添加第二个变量,但无法找到它在有效负载中的外观。
我找到了这个解决方案,但我不希望我的变量出现在标题中:
<int-http:inbound-gateway id="restCall"
request-channel="jobRunner"
supported-methods="POST"
path="/etl/{jobName}/{currentCustomer}">
<int-http:header name="jobName" expression="#pathVariables.jobName"/>
<int-http:header name="currentCustomer"/>
</int-http:inbound-gateway>
我需要类似的东西:
<int-http:inbound-gateway id="restCall"
request-channel="jobRunner"
supported-methods="POST"
path="/etl/{jobName}/{currentCustomer}"
payload-expression =
"#pathVariables.jobName,#pathVariables.currentCustomer">
</int-http:inbound-gateway>
最佳答案
有效负载是单个对象;不可能是两个。
您可以将其中一个变量添加到 <header/>
相反,或者创建一些 POJO 并使用
"new com.foo.MyVariableContainer(#pathVariables.jobName, #pathVariables.currentCustomer)"
关于java - 如何向有效负载表达式添加两个路径变量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56662443/