在SpEL中引用Map元素 - Spring FTP动态远程目录创建

时间:2013-05-19 10:25:01

标签: spring-integration spring-el

我正在使用spring integration ftp的出站通道适配器

<int-ftp:outbound-channel-adapter id="ftpOutAdapterAutoCreate"
session-factory="ftpSessionFactory" channel="outChannel"
remote-directory-expression="headers.['remotedir']" charset="UTF-8" />

在我的java代码中,我在标题中设置了远程目录。

org.springframework.integration.Message<File> messageA=
org.springframework.integration.support.MessageBuilder
.withPayload(reqFile).setHeader("remotedir",  "/errorOrders").build();

部署

时显示的错误消息
org.springframework.expression.spel.SpelParseException: EL1049E:(pos 7): 
Unexpected data after '.': 'lsquare([)'

1 个答案:

答案 0 :(得分:1)

您引用Map的元素没有句号(消息标题是Map)。语法为headers['remotedir'][之前没有点)。

另外,如果你的地图密钥中没有.,你也可以使用headers.remotedir