问题
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" />
回答1:
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 + ' Name: '+ payload.name"
回答2:
expression="'DealId: '+ payload.dealId'+ T(System).lineSeparator()+.......'"
来源:https://stackoverflow.com/questions/29668655/how-to-put-new-line-in-spring-expression-language