Finding Locale from Controller in Spring MVC

前端 未结 1 1498
不思量自难忘°
不思量自难忘° 2021-01-04 18:27

I\'m using Sprinng 3.0.

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

Thanks.

相关标签:
1条回答
  • 2021-01-04 19:20

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

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

    See also:

    • 15.3.2.3 Supported handler method arguments and return types
    0 讨论(0)
提交回复
热议问题