Rod
Rod

Reputation: 2170

Is it possible to add Html tags into Spring MVC3 I18N messages.properties file

Given the following MVC3 i18n use:

at a jsp file:

<s:message code="clickHere">

at message.properties file:

clickHere=Please click <a href="http://abc.com">Here</a>

a user's browser will display(and the word Here will be a link to http://abc.com):
Please click Here

Thanks

Upvotes: 1

Views: 2855

Answers (2)

Georgios Syngouroglou
Georgios Syngouroglou

Reputation: 19944

In any case you use Thymeleaf, instead of th:text, you should use the th:utext.
Example below:

# Instead of this
<div th:text="#{message}">text to be replaced</div>

# Use this
<div th:utext="#{message}">text to be replaced</div>

You should always keep in mind that using the th:utext can cause XSS Attacks.

In the properties file, you will obviously have the following,

# In properties
message=Text to be displayed

Upvotes: 0

pap
pap

Reputation: 27614

Did you try

<s:message code="clickHere" htmlEscape="false" />

Upvotes: 3

Related Questions