Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
基于用户偏好语言的Spring MVC 3消息属性程序加载_Spring_Spring Mvc - Fatal编程技术网

基于用户偏好语言的Spring MVC 3消息属性程序加载

基于用户偏好语言的Spring MVC 3消息属性程序加载,spring,spring-mvc,Spring,Spring Mvc,我有i18n的基本springmvc3设置,可以根据请求中用户传递的语言在页面上显示标签。例如:url?lang=fr、url?lang=de等 但实际要求是,我必须为每个语言环境维护2个属性文件,例如,对于法语,我将有messages\u fr\u fr.properties和messages\u fr\u en.properties。类似地,对于德国地区,我将有messages_de_de.properties和messages_de_en.properties 这意味着,当法国用户登录时,

我有i18n的基本springmvc3设置,可以根据请求中用户传递的语言在页面上显示标签。例如:url?lang=fr、url?lang=de等

但实际要求是,我必须为每个语言环境维护2个属性文件,例如,对于法语,我将有messages\u fr\u fr.properties和messages\u fr\u en.properties。类似地,对于德国地区,我将有messages_de_de.properties和messages_de_en.properties

这意味着,当法国用户登录时,页面将显示法语标签,但如果他愿意,他可以从下拉列表切换到英语。这需要以编程方式加载消息属性,如何执行此操作?

从,我相信使用
LocaleChangeInterceptor
可以帮助您在运行时更改语言并同样加载消息。描述了更详细的示例