unescaping text

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

unescaping text

sagargaikwad
Hi,
    I have a tag in page which contains HTML content. I want web browser to render (not display) that page. So I use utext attribute as suggested. So it worked as expected but failed for following content

B&B company. <br>some random text</br>.

It is failing because of '&'. I think, it will be escaped as other characters(like <,>) but apparently it is not.

Please let me know if I am missing something.
Reply | Threaded
Open this post in threaded view
|

Re: unescaping text

danielfernandez
Administrator
What the "th:utext" attribute does is, precisely, output *unescaped* text. That's why your <br>'s will render as line feeds instead of visible tags. "th:utext", therefore, allows you to directly output HTML code.

But "B&B" is not valid HTML. If you want to display that using a "th:utext", you'd need your String to be "B&B".

Regards,
Daniel.