How can the internationalization of spring mvc be implemented without using get request parameters?

problem description

online tutorials are usually modified like www.xxx.com/index?lang=zh-CN.
I want to make it like https://msdn.microsoft.com/zh..
wants to avoid modifying the original controller as much as possible.

May.22,2021

you can write an interceptor to modify the internationalized language
by determining whether the last path of the url is zh-cn , and then modifying the language
in fact, spring's original way to modify the language is to use the interceptor's
you can see its org.springframework.web.servlet.i18n.LocaleChangeInterceptor source code to know

.
Menu