Camel: How to include an ampersand as data in a URI (NOT as a delimiter)?(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 中包含一个与号作为数据(不作为分隔符)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Camel:如何在 URI 中包含一个与号作为数据(不作为分隔符)?
基础教程推荐
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
- RabbitMQ:消息保持“未确认"; 2022-01-01
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- 修改 void 函数的输入参数,然后读取 2022-01-01
- 使用堆栈算法进行括号/括号匹配 2022-01-01
- 存储 20 位数字的数据类型 2022-01-01
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- 如何对 Java Hashmap 中的值求和 2022-01-01
- Struts2 URL 无法访问 2022-01-01
