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

前端 未结 3 1160
慢半拍i
慢半拍i 2021-02-09 14:55

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:06

    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.");
        }
    }
    

提交回复
热议问题