I am working on a spring controller with the code snippet below :
@RequestMapping(value="/getMessage.htm", method=RequestMethod.POST)
protected String uploadFile(ModelMap model){
//... other codes
model.addAttribute("theMessage", "Hello world <b>how are you</b> today?");
return "the-view";
}
When displaying the message on the client side using JavaScript, I encountered an issue as shown in the code snippet below :
document.getElementById('theMessageSpan').innerHTML = '<c:out value="${theMessage}"/>';
Unfortunately, the displayed message appears as a string literal.
Hello world <b>how are you</b> today?
My intention is to display the message like this :
Hello world
how are you today?
Attempts to use apache commons' StringEscapeUtils.unescapeHtml
before adding the text to the ModelMap
provided no solution.
Any insights on how to solve this issue would be greatly appreciated.