61.6. 将值传递给 JSLT
在对正文应用 JSLT 表达式时,Camel 可以作为变量提供交换信息。Exchange 中的可用变量有:
| name | value |
|---|---|
| 标头 |
|
| exchange.properties |
Exchange 属性作为 json 对象。Exchange 是变量的名称,属性是 交换属性的路径。 |
所有无法通过 Jackson 转换为 json 的值都会被拒绝,且在 jslt 表达式中不可用。
例如,名为 "type" 的标头和交换属性 "instance" 可以像访问
{
"type": $headers.type,
"instance": $exchange.properties.instance
}