Change locale within page under Spring MVC + Tiles + JSTL

1.2k views Asked by At

I'm overlooking something and I hope someone can provide me with a resource on this.

I am utilizing spring 2.5.6 in my application with Tiles 2.2.2.

I have a requirement to display certain information within a page in different locales.

Right now I'm transitioning the application to utilize Spring MVC + Tiles. As such I'm also using JSTL within JSP pages.

So what I'm trying to do is set a locale at a certain point to render a date

<fmt:setLocale locale="de" />
<fmt:formatDate dateStyle="long" type="date" value="${someDate}" />

Right now, under Spring MVC + Tiles, this only renders within the page's native language context. If I do this under straight JSP though, it works fine.

I know that the "TilesView" class used by Spring exposes certain localization contexts and variables, what I don't see is whether or not this is interfering with the <fmt:setLocale /> call that I was invoking.

Thanks for any help!

1

There are 1 answers

0
Dave G On BEST ANSWER

I did some digging this morning on this. It appears that under SpringMVC+Tiles there is a localization context that is established with the TilesView. This localization context will only refer to the config value established in the session.

In the application I'm working on, we have a different locale management mechanism. What I did was when that locale is changed the value for "javax.servlet.jsp.jstl.fmt.locale" is set to the locale used in our locale change mechanism. This mitigates the need for using <fmt:setLocale /> to change the locale as there are no independent locale displays on the page.