Search code examples
grailsgrails-orm

domain class property representation on the page


I have a domain class with property which stores HTML text. I want to show this HTML directly on the page, so I want to use it in such way:

<head>
..
</head>
<body>
   ${instance.HTML}
</body>

suppose instance.HTML equals to <a>some text</a> what I get is:

<head>
..
</head>
<body>
   "<a>some text</a>"
</body>

but what I actually want to achieve is just

<head>
..
</head>
<body>
   <a>some text</a>
</body>

How to delete those quotes? Thanks!


Solution

  • This is happening because of security feature of grails: Cross Site Scripting (XSS) Prevention

    Try raw like

    ${raw(instance.HTML)}
    

    OR

    add page directive like:

    <%@page defaultCodec="none" %>