我有一個http-inbound-gateway,我想要檢索一個請求參數來填充入站通道作爲有效負載。我發現http-inbound-gateway支持spring表達式,所以我可以使用#requestParams來檢索請求參數。看起來#requestParams相當於request.getParameters('key'),它返回一個Map,但我希望調用request.getParameter('key'),它返回一個String。目前我必須使用新的字符串(#requestParams ['key'])來解決這個問題。有沒有更好的方法來做到這一點?如何在Spring集成http-inbound-gateway中通過spring el檢索請求參數?
<int-http:inbound-gateway path="/mypath"
supported-methods="GET" payload-expression="new String(#requestParams['key']?:'')"
request-channel="inboundChannel" reply-channel="outboundChannel"
error-channel="errorChannel"
message-converters="stringHttpMessageConverterUsingUtf8">
</int-http:inbound-gateway>
謝謝,很好的建議。 – Hippoom