骆驼(Camel):如何在URI中将“&"作为数据(不作为分隔符)? [英] Camel: How to include an ampersand as data in a URI (NOT as a delimiter)?

查看:109
本文介绍了骆驼(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抛出带有未知参数= [{bar = null}]"的ResolveEndpointFailedException.

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

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

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

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

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

我尝试使用URISupport创建URI.它逃脱了&到%26,然后再次得到未知参数= [{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"

在上面的示例中,我们将密码值声明为raw,并且 实际的密码应与输入的密码相同,例如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/融合/显示/CAMEL/如何+做+ I +配置+端点

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

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