Pregunta

I'm trying to grab a key/value pair from some resource bundles I'm asked to work with

Normally within our block of HTML (in a JSP file) we might have something like

<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<h1><spring:message code="gr.common.title"/></h1>

However, I want to do something with the String in Java before outputting it in HTML, something like

<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%
// pseudo below
String foo = "This is my %s title".format(PSEUDO_MESSAGE("gr.common.title"));
%>
<h1><%= foo %></h1>

I found this example but this seems to be within a .java file or equivalent

¿Fue útil?

Solución

You can use the core tag lib set tag

<c:set var="toDoSomeFormat">
    <spring:message code="gr.common.title" />
</c:set>

The set element takes its value from its content.

Then use your formatting with ${toDoSomeFormat}

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top