I have a domain. User with a field description. In my Grails GSP page I can display it as:
${user.description}
The problem is that description contains valid html content like this:
<ul><li>test</li><li>test2</li><li>test3</li></ul><br>
This content should be rendered to be visible as HTML instead of a String.
How can I render a String containing HTML as HTML on a GSP?
To generate raw
output use any of the following:
${raw(user.description)}
or
${user.description.encodeAsRaw()}
You can read this blog post that details this further. In later versions the default codec being used is HTML. You can control the default codec via Config.groovy
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With