【问题标题】:Http inbound-gateway using optional request parameters使用可选请求参数的 Http 入站网关
【发布时间】:2015-02-03 17:47:09
【问题描述】:

我想知道我是否遗漏了与 http 入站网关相关的内容。我想使用可选参数执行搜索(结果将是 json)。以下是已定义网关的示例:

<int-http:inbound-gateway id="inboundSearchRequestGateway" supported-methods="GET, POST" request-channel="searchRequest" reply-channel="searchResults"
  mapped-response-headers="Return-Status, Return-Status-Msg, HTTP_RESPONSE_HEADERS" view-name="/test123" path="/search" reply-timeout="50000"
  error-channel="errorChannel">
   <int-http:header name="param1" expression="#requestParams.param1"/>
   <int-http:header name="param2" expression="#requestParams.param2"/>
</int-http:inbound-gateway>

目前我必须提供两个参数才能进行搜索,否则请求不会传递到请求通道。

有问题的搜索目前没有使用参数。

这将返回结果: http://localhost/test123/search?param1=123&amp;param2=234

虽然这不会返回任何内容: http://localhost/test123/search?param1=123

是否有其他方法可以将请求参数映射到集成消息标头中,以便在链中进行进一步处理?这甚至可能是一个错误吗?

我正在使用 Spring Integration 4.1.2、Windows、Java 7。

谢谢。

T

【问题讨论】:

    标签: spring-integration


    【解决方案1】:

    由于requestParamsMap,因此将#requestParams['param2'] 用作可选参数。使用点分语法需要参数存在。

    【讨论】:

    • 完美。我知道我缺少一些简单的东西。再一次......来自 Spring 团队的惊人响应时间。谢谢加里。
    猜你喜欢
    • 2015-03-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-01
    • 1970-01-01
    • 2018-02-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多