如何在 Spring 表达式语言中添加“换行符”?

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

转到新行的确切 SpEL 表达式是什么。这是我的配置:

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

您可以使用此作为解决方法:

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

编辑:

澄清一下,SpEL 支持转义字符,问题是 java DOM 解析器不理解转义。

这也行...

expression="'DealId: '+ payload.dealId + '&#10;Name: '+ payload.name"
expression="'DealId: '+ payload.dealId'+  T(System).lineSeparator()+.......'"