PDA

View Full Version : Internationalization messages in HTML tags


Rexxe
08-14-2004, 01:11 PM
Does anyone know how to pull a message out of the messages.properties file and use it as the value in a button?

For example,

messages.properties would look like:

label.search=Search

on the jsp I want:

<input type="button" value="<spring:message code="label.search"/>">

I want the button to say Search, but of course it doesn't, it says what I put in those quotes. Thoughts?

Thanks!

dmiller
08-14-2004, 01:16 PM
Are you sure you've put the spring taglib directive at the top of your JSP? Are other <spring:xxx> tags working?

Rexxe
08-14-2004, 01:57 PM
Yeah, I'm using the <spring:message> tag all over the page and they are showing up correctly. It's just when I put it inside an HTML tag like I showed that it doesn't work.

dmiller
08-14-2004, 02:58 PM
All I can think of is to try the equivalent jstl tag: <fmt:message ... >. It's the same as <spring:message> as far as I know. I use that regularly in the exact scenario you are talking about and it's never been a problem.

Sorry I don't have any better advice :cry:

elendal
08-14-2004, 11:19 PM
<input type="button" value="<spring:message code="label.search"/>">

I want the button to say Search, but of course it doesn't, it says what I put in those quotes. Thoughts?

Thanks!

Try
<input type="button" value='<spring:message code="label.search"/>'>

bullgod
09-20-2004, 08:51 AM
If you have EL, this works too... more verbose imho:


<spring:message code="my.button" var="tmpMyButton"/>
<input type="button" value"${tmpMyButton}">


/a