Camel:如何在 URI 中包含一个与号作为数据(不作为分隔符)? [英] Camel: How to include an ampersand as data in a URI (NOT as a delimiter)?

查看:25
本文介绍了Camel:如何在 URI 中包含一个与号作为数据(不作为分隔符)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(骆驼 2.9.2)

非常简单的用例,但我似乎找不到答案.我的代码归结为:

Very simple use case, but I can't seem to find the answer. My code boils down to this:

String user = "user";
String password = "foo&bar";

String uri = "smtp://hostname:25?username=" + user +
    "&password=" + password + 
    "&to=somthing@something.com"; // etc. You get the idea

from("seda:queue:myqueue").to(uri);

Camel 引发 ResolveEndpointFailedException,并带有未知参数=[{bar=null}]".

Camel throws a ResolveEndpointFailedException with "Unknown parameters=[{bar=null}]."

如果我尝试foo%26bar",我会得到相同的结果.

If I try "foo%26bar," I get the same result.

如果我尝试foo&bar",骆驼会以未知参数=[{amp;bar=null}]."

If I try "foo&bar" camel responds with "Unknown parameters=[{amp;bar=null}]."

我尝试使用 URISupport 创建 URI.它逃脱了 &到 %26,然后我再次得到Unknown parameters=[{bar=null}]".

I tried using URISupport to create the URI. It escapes the & to %26, and then I get "Unknown parameters=[{bar=null}]" again.

有什么想法吗?

推荐答案

从 Camel 2.11 开始,您可以使用原始语法

As from Camel 2.11 you could use raw syntax

例如:

.to("ftp:joe@myftpserver.com?password=RAW(se+re?t&23)&binary=true"

在上面的示例中,我们将密码值声明为原始值,并且实际密码将与输入的密码相同,例如 se+re?t&23

In the above example, we have declare the password value as raw, and the actual password would be as typed, eg se+re?t&23

https://cwiki.apache.org/confluence/display/CAMEL/How+do+I+configure+endpoints

这篇关于Camel:如何在 URI 中包含一个与号作为数据(不作为分隔符)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆