How to obtain a current user locale from Spring without passing it as a parameter to functions?

前端 未结 3 1289
轻奢々
轻奢々 2020-12-07 16:38

I am using Spring 3.1 and want to find the locale active for the current user is there a way to grab the locale directly without being forced to pass it from the controller

3条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-07 17:02

    We had the same need, so came up with putting Locale into ThreadLocal context. We already had an object (some user information) stored in ThreadLocal context, so just appended it (looks like a hack, but the quickest solution we found).

提交回复
热议问题