使用 SPeL 的 Spring Integration 过滤器表达式
我有一个包含允许值列表的配置 bean:
@Component
public class Conf {
public List<String> getAllowedValues() {
return Arrays.asList("A", "B", "C", "D");
}
我已使用名为“someValue”的字段填充了消息头,并且我想使用过滤器元素来排除 someValue 不在允许值列表中的消息。
我的上下文如下所示:
<int:filter expression="#{conf.allowedValues}.contains(headers.get('someValue'))"/>
但我得到: SpelParseException: EL1041E:(pos 1): After parsing a valid expression, there is still more data in the expression: 'comma(,)'
I have a configuration bean that has a list of allowed values:
@Component
public class Conf {
public List<String> getAllowedValues() {
return Arrays.asList("A", "B", "C", "D");
}
I have populated my message headers with a field called 'someValue' and I want to use a filter element to exclude messages where someValue is not in the allowed values list.
My context looks like this:
<int:filter expression="#{conf.allowedValues}.contains(headers.get('someValue'))"/>
But I get: SpelParseException: EL1041E:(pos 1): After parsing a valid expression, there is still more data in the expression: 'comma(,)'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
答案在此处提供:
The answer was provided here:
我对此有一个更简单(也许不是最好)的解决方案。
参考
I got a simpler (maybe not the best) solution for this.
reference