Search code examples
jspspring-mvcjstl

JSTL with fn functions


I have a project based in Spring Web model-view-controller (MVC) framework. The version of the Spring Web model-view-controller (MVC) framework is 3.2.8.

in my JSP

${fn:toUpperCase(<fmt:message key="${description.language.label}" />)}

but I got this error

weblogic.servlet.jsp.CompilationException: deviceInfo.jsp:118:61: Syntax error in expression. Encountered "<". Expected one of : <INTEGER_LITERAL>, <FLOATING_POINT_LITERAL>, <STRING_LITERAL>, "true", "false", "null", "(", ")", "!", "not", "empty", "-", <IDENTIFIER>,
${fn:toUpperCase(<fmt:message key="${description.language.label}" />)}
^

Solution

  • The <fmt:message> tag inside a ${ } expression doesn't work. You can set a temporary variable to contain the message output and use that inside the expression:

    <c:set var="msg">
      <fmt:message key="${description.language.label}" />
    </c:set>
    
    ...
    
    ${fn:toUpperCase(msg)}