spring MVC语言环境的cookie默认命名为org.springframework.web.servlet.i18n.CookieLocaleResolver.LOCALE
。
如何将此名称设为另一个名称?
答案 0 :(得分:3)
答案 1 :(得分:2)
使用Java配置:
@Bean
public HandlerInterceptor localChangeInterceptor(){
LocaleChangeInterceptor localeInterceptor = new LocaleChangeInterceptor();
localeInterceptor.setParamName("lang");
return localeInterceptor;
}
使用XML配置:
<mvc:interceptors>
<bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
<property name="paramName" value="lang" />
</bean>
</mvc:interceptors>
答案 2 :(得分:1)
Java配置方式:
@Bean
public LocaleResolver localeResolver() {
final CookieLocaleResolver cookieLocaleResolver = new CookieLocaleResolver();
cookieLocaleResolver.setDefaultLocale(Locale.ENGLISH);
cookieLocaleResolver.setCookieName("YOUR_LOCALE_COOKIE_NAME");
return cookieLocaleResolver;
}