How to display HTML markup content from database record to browser properly in Struts 2?

I have a simple text stored in the database record: Hello wrapped in an h1 tag.

When I print this record in the JSP with the <s:property /> tag, it displays:

<h1>Hello</h1>

While I want it to be displayed like:

Hello

How can I get the interpreted value, instead of the source value ?

Upvotes: 3

Views: 758

Answers (1)

Andrea Ligios
Andrea Ligios

Reputation: 50203

You need to set the escapeHtml attribute of the <s:property/> tag to false because, for security reasons, it is true by default:

<s:property value="myVar" escapeHtml="false" />

Read more on the docs.

Upvotes: 2

Related Questions