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

前端 未结 3 1267
轻奢々
轻奢々 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:09

    It depends on where you have configured to store the locale, in session or in cookie?

    In my application I have configured to store the user locale in its session with below mentioned configuration.

        
            
        
    
        
            
        
    
        
            
        
    
        
            
            
                /WEB-INF/i18n/labels
                /WEB-INF/i18n/messages
                /WEB-INF/i18n/include
            
            
            
        
    

    If you have done somthing like this then you can easily retrieve the locale parameter from the session.

    Hope this helps you.

    Cheers.

提交回复
热议问题