views:

2003

answers:

1

I'm developing a Java/Spring web application. The problem I'm currently facing is that I'd like to have message from message.resources shown as an attribute in an HTML.

<input type="submit" name="login" value="login" />

So instead of the hardcoded value "login" I need to the value of

<spring:message code="general.submit" /> as the value attribute of that input tag. As the pages are all xml, it's no option to nest tags like

<input type="submit" name="login" value="<spring:message code="general.submit" />" />

as it does not compile. I could, of course, read the value in the Java controller and use a JSTL variable to display the value, but I think it would be too hackish and complicated, especially for pages with large amount of submit buttons. Is there some kind of elegant way of accomplishing what I want to do?

+1  A: 

Use <spring:message> to store the value in a var, then reference that var using EL, e.g.

<spring:message code="general.submit" var="submitText"/>
<input type="submit" name="login" value="${submitText}" />
skaffman