Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 513
Czar Avatar asked Dec 14 '10 16:12

Czar


1 Answers

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

like image 117
Aravind Yarram Avatar answered Sep 23 '22 16:09

Aravind Yarram