第 14 章 常数
概述
恒定语言是一个简单的内置语言,用于指定纯文本字符串。这样便可在预期表达式类型的任何上下文中提供纯文本字符串。
XML 示例
在 XML 中,您可以将 用户名
标头设置为值 Jane Doe
,如下所示:
<camelContext> <route> <from uri="SourceURL"/> <setHeader headerName="username"> <constant>Jane Doe</constant> </setHeader> <to uri="TargetURL"/> </route> </camelContext>
<camelContext>
<route>
<from uri="SourceURL"/>
<setHeader headerName="username">
<constant>Jane Doe</constant>
</setHeader>
<to uri="TargetURL"/>
</route>
</camelContext>
Java 示例
在 Java 中,您可以将 用户名
标头设置为值 Jane Doe
,如下所示:
from("SourceURL") .setHeader("username", constant("Jane Doe")) .to("TargetURL");
from("SourceURL")
.setHeader("username", constant("Jane Doe"))
.to("TargetURL");