Search code examples
javaspringspring-el

escaping colon ":" in SpEL expression


I am trying to build a url in a spring integration flow like shown:

<int:header name="url" expression="${gateway.protocol}+'://'+${gateway.host}+':'+#{systemProperties['integration-test.port']}?:${gateway.port}+'/'+${gateway.context}" />

however I continuously get the following error:

SpelParseException: EL1041E:(pos 9): After parsing a valid expression, there is still more data in the expression: '':''

I have tried using \ and \\ and as you can see I have single quotes around it, which according the documentation here http://docs.spring.io/spring/docs/3.0.x/spring-framework-reference/html/expressions.html should be enough.

any help would be much appreciated.

thanks


Solution

  • You need single quotes ' around your placeholder(s)...

    expression="'${gateway.protocol}'+'://'+'${gateway.host}'+ ...
    

    Otherwise whatever they resolve to will be evaluated by SpEL.

    Or...

    expression="'${gateway.protocol}://${gateway.host} ... '"