4
votes

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?

1

1 Answers

10
votes

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.