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

风格不统一 提交于 2019-12-24 03:38:06

问题


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 + '&#10;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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!