How do you enable LocaleInterceptor to change the locale in spring-security login page?

前端 未结 3 980
醉话见心
醉话见心 2021-02-09 14:45

Pardon me if this question has been asked before, but I haven\'t gotten a straight answer that helped me solve my problem. I have a gwt application that I have secured using sp

3条回答
  •  醉话见心
    2021-02-09 15:04

    First the key is the LocaleResolver and forget the interceptor.

    Just create a bean that implement this interface to resolve the locale from where you save it, as example from an attribute of the request.

    public class LocaleResolverImpl implements LocaleResolver {
    
        public LocaleResolverImpl() {
        }
    
        @Override
        public Locale resolveLocale(HttpServletRequest request) {
            Locale r = (Locale) request.getAttribute("localeObject");
            return r == null ? request.getLocale() : r;
        }
    
        @Override
        public void setLocale(HttpServletRequest request, HttpServletResponse response, Locale locale) {
            throw new UnsupportedOperationException("Not supported yet.");
        }
    }
    

提交回复
热议问题