Java Spring集成将路径变量和post主体组合在有效负载表达式中
使用http入站网关,我能够使用SPEL指定有效负载表达式,该表达式将访问header、requestParams和pathVariables。我如何也包括来自帖子的正文?我目前拥有的一个例子是Java Spring集成将路径变量和post主体组合在有效负载表达式中,java,spring,spring-integration,spring-el,Java,Spring,Spring Integration,Spring El,使用http入站网关,我能够使用SPEL指定有效负载表达式,该表达式将访问header、requestParams和pathVariables。我如何也包括来自帖子的正文?我目前拥有的一个例子是 <int-http:inbound-gateway path="/document/{product}/{id}/blah" supported-methods="GET" request-ch
<int-http:inbound-gateway path="/document/{product}/{id}/blah"
supported-methods="GET"
request-channel="documentService.blah"
reply-channel="httpReplyChannel"
message-converters="jsonMessageConverter"
header-mapper="defaultHttpHeaderMapper"
payload-expression="new RequestDTO(
#pathVariables.product,
#pathVariables.id,
#requestParams['optionalParam'],
headers.get('headerKey')) />
是的,这是可能的。
有效负载表达式将评估上下文与HttpEntity一起用作根对象,
#请求参数和#路径变量变量。
所以,如果你把它改成POST,你可以得到一具尸体
payload-expression="new RequestDTO(
#pathVariables.product,
#pathVariables.id,
#requestParams['optionalParam'],
headers.get('headerKey'),
body)"
这只是因为HttpEntity有那个getter 阿泰姆,谢谢,这不仅仅是清理身体。我一直不明白负载表达式使用的是什么上下文。我确信这是我在文档中浏览过多次的东西,但它没有点击。谢谢你完整的回答!