【问题标题】:Spring Integration filter expression using SPeL使用 SPeL 的 Spring Integration 过滤器表达式
【发布时间】:2011-09-29 13:29:27
【问题描述】:

我有一个包含允许值列表的配置 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(,)'

【问题讨论】:

    标签: spring-integration spring-el


    【解决方案1】:

    答案已提供here:

    <int:filter expression="@conf.allowedValues.contains(headers.get('someValue'))"/>
    

    【讨论】:

      【解决方案2】:

      对此我有一个更简单(也许不是最好的)解决方案。

      <int:filter expression="{"A", "B", "C", "D"}.contains(headers.get('someValue'))" />
      

      reference

      【讨论】:

        猜你喜欢
        • 2019-07-20
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-07-20
        • 1970-01-01
        • 2014-01-14
        • 1970-01-01
        相关资源
        最近更新 更多