Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/348.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java HTTP入站适配器区分受支持的方法_Java_Spring_Http_Spring Integration - Fatal编程技术网

Java 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

我有一个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-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方法]

FYI
REQUEST\u URL
USER\u PRINCIPAL
也被填充;而且,在适配器/网关上,还可以使用http请求参数或URI变量填充其他头