Property tag of struts2 using a properties file with html tags

Viewed 115

I am migrating a Struts1 project to Struts2. It has a properties file with html tags like below.

properties file

profile.instruction.ordersearch=Enter the search criteria,and then click <b>Search</b>.

Struts 1

jsp

<bean:message key="profile.instruction.ordersearch" />

Output

Enter the search criteria,and then click Search.

Struts 2

I replaced the bean tag with an s:property for Struts 2.

jsp

<s:property value="getText('profile.instruction.ordersearch')"/>

Output

Enter the search criteria,and then click <b>Search</b>.

As you can see, the "Search" text is not bold like in Struts 1 and is getting displayed with the tags. Is there a way to get the property tag to show it like struts 1 using the property tag.

1 Answers

You need to set the escapeHtml attribute in s:property tag to false: This should work.

<s:property escapeHtml="false" value="getText('profile.instruction.ordersearch')"/>
Related