JSP: Problem Using Spring Message with JSTL

Couple of days back I was trying to externalize the labels and messages in a JSP file to a property file. As I was using Spring MVC, decided to use <spring:message> tag to achieve this. Everything else worked fine except when I used <spring:message> tag as a value attribute of <c:set>. Albeit it sounds very simple, I had to spend some time finding out the way. And hence considering this a candidate for my blog.


Unable to use <spring:message> tag with the JSTL  <c:set> tag like below:

<c:set var=”someVar” value=”<spring:message code=’some.value’/>” />

Nest the <spring:message> tag in the JSTL tag.

<c:set var=”someVar”>
<spring:message code=”some.value”/>

Enjoy Learning,