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
精彩评论