Nogothwen
Nogothwen

Reputation: 77

link inside a property in Struts2

I'm trying to show a property in my jsp page:

<s:property value="News"/>

where in news I want to put some text and a link

in the jsp page it shows the mere tag without "compiling it"

I tried

This is a news follow the <s:a href="http://www.google.it">link</s:a>

and

This is a news follow the <a href="http://www.google.it">link</a>

How can it be done this?

Upvotes: 1

Views: 549

Answers (1)

Andrea Ligios
Andrea Ligios

Reputation: 50281

This is a news follow the <s:a href="http://www.google.it">link</s:a>

This can't work because you can't nest Struts tags, hence it'll become:

<s:property value="This is a news follow the <s:a href="http://www.google.it">link</s:a>"/>

which is invalid.

The second instead:

This is a news follow the <a href="http://www.google.it">link</a>

will result in

<s:property value="This is a news follow the <a href="http://www.google.it">link</s:a>"/>

which is valid, but will be translated in pure text in the JSP.

To obtain the real HTML object, you need to disable the HTML escaping functionality:

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

Upvotes: 1

Related Questions