开发者

Spring Integration filter expression using SPeL

开发者 https://www.devze.com 2023-03-17 11:33 出处:网络
I have a configuration bean that has a list of allowed values: @Component public class Conf { public List<String> getAllowedValues() {

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开发者_如何学Go 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(,)'


The answer was provided here:

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


I got a simpler (maybe not the best) solution for this.

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

reference

0

精彩评论

暂无评论...
验证码 换一张
取 消