Spring message in JSTL tag

According to this post from 3 years ago, the only way to display the spring message in the jstl tag is to wrap it in <c:set var="someVar"> , which does the "work", but it seems very far from ideal.

Speed ​​up 3 years, is this the only way to handle this?

Here is my code

It works, but not "perfect"

 <c:set var="closeMessage"> <spring:message code='lman.ilr.closeItemDetail'/> </c:set> <dsg:sidePanelContent closePanelText="${closeMessage}"> 

Does not work, returns the string <spring:message code='lman.ilr.closeItemDetail'/>

 <dsg:sidePanelContent closePanelText="<spring:message code='lman.ilr.closeItemDetail'/>"> 
+5
source share
3 answers

The spring message tag, like fmt:message , has a var attribute that can be used to store the message, not display it.

Always helps to read the documentation .

Also, your incorrect message probably comes from forgetting to declare taglib spring at the top of your JSP.

+8
source

In case of reference

 <c:choose> <c:when test="${serviceVO.id eq 0}"> <spring:message code="label.service.createservice" var="buttonName"/> </c:when> <c:otherwise> <spring:message code="label.updateservice" var="buttonName"/> </c:otherwise> </c:choose> <c:out value="${buttonName}"> //Prints the desired value... 
+4
source

I think what you want to do is.

then

0
source

Source: https://habr.com/ru/post/1494306/


All Articles