我正在尝试设置 Spring MVC 3.0 以支持本地化。消息位于 messages_en.properties 和 messages_fr.properties 中。它可以工作,但我不知道如何支持本地化 JSP 页面。例如,我尝试将它们命名为sample_en.jsp,但它不起作用。
我使用ControllerClassNameHandlerMapping、BeanNameViewResolver和InternalResourceViewResolver、LocaleChangeInterceptor和SessionLocaleResolver。
有什么想法吗?
最佳答案
JSP 本地化的典型方法是使用 fmt:message
(或 spring:message
)从 .properties
文件呈现本地化字符串。它不需要为不同的区域设置维护不同版本的页面标记。
不支持开箱即用的带有本地化 JSP 文件的 approah,尽管它可以通过子类化 InternalResourceViewResolver
和重写 loadView()
来实现。
关于java - Spring MVC 中的sample_en.jsp 和sample_fr.jsp,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2353407/