【问题标题】:Setting Query Parameteres in REST在 REST 中设置查询参数
【发布时间】:2025-11-26 21:55:02
【问题描述】:

我正在使用 restlet 来消费一个 URL。

我正在使用 XML DSL 创建一个动态 URL。

即使我像下面这样硬编码参数值

<toD uri="restlet:https://---URL---:443/claims/id/?userId=1&amp;id=25?restletMethod=GET" />

我收到以下错误

Restlet operation failed invoking https://---URL---:443/employee/id/?id=25%3FrestletMethod%3DGET&userId=1

如何为这些动态 URL 设置参数?

【问题讨论】:

  • 注意 restlet 已被弃用(camel.apache.org/components/2.x/restlet-component.html) 也许你应该改用 http 或 http4 组件。如果您继续使用restlet,则可以通过为 CamelHttpUri 标头设置一个值来构造 URI。
  • 请注意,您的 uri 中有 多个 个问号:?userId=...?restletMethod=GET !

标签: spring rest apache-camel dsl restlet


【解决方案1】:

您的查询字符串中似乎有第二个问号 (?)。即:id=25?restletMethod=GET

<toD uri="restlet:https://---URL---:443/claims/id/?userId=1&amp;id=25?restletMethod=GET" />

您可能应该将其替换为另一个 & 符号 (id=25&restletMethod=GET)

【讨论】: