Reputation: 1424
I'm trying to show é
as a title of my form:input
field, and I can't get it working.
<form:input type="text" path="something" title="é"/>
<input type="text" title="<spring:message code="mySpecialChar" />"/>
<form:input type="text" path="something" title="<spring:message code="mySpecialChar" />"/>
Error, I'm not allowed to do that, to solve this, I've tried Example 4.
<spring:message code=mySpecialChar" var="mySpecialChar"/>
<form:input type="text" path="something" title="${mySpecialChar}"/>
How can I get my Example 4 working properly ?
Upvotes: 0
Views: 223
Reputation: 28569
You would need to unescape your value in a Controller, first thing you would have to autowire your MessageSource
@Autowired
private MessageSource messageSource;
than you can unescape using e.g. StringEscapeUtils
String message = messageSource.getMessage("mySpecialChar", null, Locale.getDefault());
model.addAttribute("mySpecialChar", StringEscapeUtils.unescapeHtml([YOUR VALUE]));
than just
<form:input type="text" path="something" title="${mySpecialChar}"/>
Upvotes: 1
Reputation: 1424
After a quick search, I've found that I have to add htmlEscape="false"
to my <spring:message>
tag.
Upvotes: 1