在Spring MVC中从控制器中查找语言环境 [英] Finding Locale from Controller in Spring MVC

查看:108
本文介绍了在Spring MVC中从控制器中查找语言环境的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Sprinng 3.0.

I'm using Sprinng 3.0.

如何在基于注释的控制器中找到LocaleResolver设置的当前语言环境?

How do I find the current locale set by a LocaleResolver within an annotation-based controller?

谢谢.

推荐答案

您可以在控制器方法中声明类型为Locale的参数:

You can declare an argument of type Locale in your controller method:

@RequestMapping
public ModelAndView foo(..., Locale locale) { ... }

另请参见:

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆