Czar
Czar

Reputation: 366

What to use for localization in JSPs with Spring?

I have a Spring MVC webapp that used messages_xx.properties files. Currently I use

<fmt:message key="all.header.menu.items.start"/>

in my files. I just saw another tutorial reccomending

<spring:message code="all.header.menu.items.start"/>

Can anyone tell the difference? What are PROs and CONs?

Thanks!

Upvotes: 5

Views: 2323

Answers (1)

Aravind Yarram
Aravind Yarram

Reputation: 80176

rom the tag's doc here

It closely resembles JSTL's fmt:message-tag, however, the MessageSource classes can be integrated with the Spring context. Also, the spring:message- tag, works with the locale support that comes with Spring. Regards an HTML escaping setting, either on this tag instance, the page level, or the web.xml level. Can also apply JavaScript escaping.

If "code" isn't set or cannot be resolved, "text" will be used as default message. Thus, this tag can also be used for HTML escaping of any texts.

Here is another usage that is not supported by standard jstl

And here is 1 gotcha of using spring:message

Upvotes: 5

Related Questions