【发布时间】:2015-04-30 16:08:12
【问题描述】:
先决条件
- Apache Tomcat 7
- 春季 3.2.11.RELEASE
- Apache Camel 2.14.1
- Camel HTTP 端点 (
<artifactId>camel-http</artifactId>)
问题
目前我使用以下代码将 POST-Parameters 设置为消息正文。 骆驼HTTP-Component读取参数并发送。
.setHeader(Exchange.HTTP_METHOD, constant(HttpMethods.POST.name()))
.setHeader(Exchange.CONTENT_TYPE, constant("application/x-www-form-urlencoded; charset: UTF-8"))
.setHeader(Exchange.CONTENT_ENCODING, constant("UTF-8"))
.setBody("parameter1=a¶meter2=b")
问题在于某些参数本身就是 URL。 所以像这样的东西应该作为 POST-Request 发送:
postparameter1=a&postparameter2=http://www.`...`.com?urlparam1=value1&urlparam2=value2&postparameter3=b
我的问题是如何发送“http://www.....com?urlparam1=value1&urlparam2=value2”作为 postparameter2 的值。
提前致谢。
问候,
最大
【问题讨论】:
-
您是否尝试过使用
java.net.URLEncode.encode?
标签: java http http-post apache-camel