We are prototyping an otherwise simple Spring MVC application with a single twist:
We’ll have separate FreeMarker template files for the different locales.
So for the view “homepage” with locale US English, the viewresolver should find the template file homepage_en_us.ftl
Failing that, homepage_en.ftl, failing that homepage.ftl
Just like property files.
I know it’s better to have one template with messages, but the template files are exposed to users who are more comfortable copy-pasting than the resource abstraction, and they may have to make actual layout changes for the different locales.
What’s the most Springy way to achieve this?
This is the default behaviour?
I have my view resolver defined like:
… and it will, when asked for a view of
foo, pickfoo_en.ftloverfoo.ftl?If you’re using a custom view resolver, you might want to get it to use
org.springframework.web.servlet.viewAbstractTemplateViewResolverso you get all the cool behaviour for free?