Search code examples
springspring-integrationspring-el

How to put “new line” in Spring Expression Language?


What would be the exact SpEL expression to go to the new line. Here is my configuration:

 <logging-channel-adapter id="log"
    channel="loggingChannel" level="INFO" 
    expression="'DealId: '+ payload.dealId \n + 'Name: '+ payload.name" />

Solution

  • You can use this as a work-around:

    <int:logging-channel-adapter id="loggingChannel" logger-name="tapInbound"
        expression="'DealId: '+ payload.dealId + T(System).getProperty('line.separator') + 'Name: '+ payload.name"
        level="INFO" />
    

    EDIT:

    Just to clarify, SpEL supports escape characters, the problem is the java DOM parser doesn't understand escapes.

    This works too...

    expression="'DealId: '+ payload.dealId + '&#10;Name: '+ payload.name"