Java HTTP入站适配器区分受支持的方法
我有一个http入站适配器,定义如下-Java HTTP入站适配器区分受支持的方法,java,spring,http,spring-integration,Java,Spring,Http,Spring Integration,我有一个http入站适配器,定义如下- <int-http:inbound-channel-adapter id="httpInboundAdapter" channel="receiveChannel" name="/inboundAdapter.htm" supported-methods="GET, POST" /> <int:channel id="receiveChannel"/> <int:service-activator input-channe
<int-http:inbound-channel-adapter id="httpInboundAdapter"
channel="receiveChannel"
name="/inboundAdapter.htm"
supported-methods="GET, POST" />
<int:channel id="receiveChannel"/>
<int:service-activator input-channel="receiveChannel" expression="@sayHello.sayHello(payload)" />
我希望能够区分GET和POST请求,并以不同的方式响应它们。我怎么能做到这一点 接收频道上的消息将有一个标题
http\u requestMethod
设置为“GET”或“POST”
您可以使用expression=“@sayHello.sayHello(负载,头['http_requestMethod'])”
,其中第二个参数是字符串
为了避免硬编码文本,可以使用headers[T(org.springframework.integration.http.HttpHeaders).REQUEST\u方法]
FYIREQUEST\u URL
和USER\u PRINCIPAL
也被填充;而且,在适配器/网关上,还可以使用http请求参数或URI变量填充其他头