我正在使用Spring集成的Ftp出站网关从远程ftp服务器获取文件。我正在环境的本地目录中创建文件的副本。 我的问题是如果它们包含诸如é,ú,á,í,ü的特殊字符,我将无法获取名称正确的文件夹。我的系统配置正确,它仅不适用于通过此网关检索的文件。
谢谢您的每一个回答。
我的配置如下:
FtpOutboundGateway gateway = new FtpOutboundGateway(
delegatingSessionFactory(runtimeSessionFactoryLocator),
"mget",
"payload"
);
gateway.setOptions("-P -R");
gateway.setFilter(new AcceptOnceFileListFilter<FTPFile>());
gateway.setFileExistsMode(FileExistsMode.REPLACE_IF_MODIFIED);
gateway.setAutoCreateLocalDirectory(true);
gateway.setLocalDirectoryExpression(new SpelExpressionParser()
.parseExpression("'" + this.ftpStoragePath + "'" + "+#remoteDirectory")
);
我发现Spel可能会对那些特殊字符产生一些问题,但没有找到避免这种情况的解决方案。
编辑:我想出了一个解决方案。我错过了DefaultFtpsSessionFactory,在那里我可以使用.setControlEncoding(“ UTF-8”);
我想出了一个解决方案。我错过了DefaultFtpsSessionFactory,在那里我可以使用.setControlEncoding(“ UTF-8”);