问题
In my gsp page is the following code
<p>
${ confirmationTemplate?.body?.replace('\n', '<br/>') }
</p>
The page renders as follows
> Dear Participant, <br/> <br/>Thanks for registering to our event. The
> event will start shortly. <br/> <br/>Please collect your bibs before
> the race. <br/> <br/>Cheers, <br/>Swat Kats
The < br/> should not be printed but that should cause new line. How can i solve this problem? I appreciate any help! Thanks!
回答1:
<%request.setAttribute("vEnter", "\n");%>
${fn:replace(blindItem.blindShowModeStr,vEnter,"<BR />") }
回答2:
Look at this article http://mrhaki.blogspot.ru/2013/11/grails-goodness-generating-raw-output.html
${raw(confirmationTemplate?.body?.replace('\n', '<br/>'))}
The example above will work with grails version > 2.3
来源:https://stackoverflow.com/questions/43317231/how-to-convert-raw-br-in-gsp-to-break-row