From b42bc7b3812db702dd0d5315ac09e909cfa5bb4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johnny=20Miller=20=28=E9=94=BA=E4=BF=8A=29?= Date: Fri, 19 Feb 2021 17:40:38 +0800 Subject: [PATCH] perf($Starter): simplify internationalization (i18n) [skip ci] --- .../configuration/WebMvcConfiguration.java | 30 ++----------------- 1 file changed, 2 insertions(+), 28 deletions(-) diff --git a/spring-cloud-starter/src/main/java/com/jmsoftware/maf/springcloudstarter/configuration/WebMvcConfiguration.java b/spring-cloud-starter/src/main/java/com/jmsoftware/maf/springcloudstarter/configuration/WebMvcConfiguration.java index 9cfe1ab3..1ff00531 100644 --- a/spring-cloud-starter/src/main/java/com/jmsoftware/maf/springcloudstarter/configuration/WebMvcConfiguration.java +++ b/spring-cloud-starter/src/main/java/com/jmsoftware/maf/springcloudstarter/configuration/WebMvcConfiguration.java @@ -1,11 +1,9 @@ package com.jmsoftware.maf.springcloudstarter.configuration; -import org.springframework.context.annotation.Bean; +import lombok.RequiredArgsConstructor; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.CorsRegistry; -import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; -import org.springframework.web.servlet.i18n.LocaleChangeInterceptor; /** *

WebMvcConfiguration

@@ -16,15 +14,12 @@ * @date 1/23/20 9:02 AM **/ @Configuration +@RequiredArgsConstructor public class WebMvcConfiguration implements WebMvcConfigurer { /** * Max age: 3600 seconds (1 hour) */ private static final long MAX_AGE_SECS = 3600; - /** - * Default name of the locale specification parameter: "lang". - */ - private static final String DEFAULT_PARAM_NAME = "lang"; /** * Configure cross origin requests processing. @@ -38,25 +33,4 @@ public void addCorsMappings(CorsRegistry registry) { .allowedMethods("HEAD", "OPTIONS", "GET", "POST", "PUT", "PATCH", "DELETE") .maxAge(MAX_AGE_SECS); } - - /** - * An interceptor bean that will switch to a new locale based on the value of the lang parameter appended to a - * request. - * - * @return the locale change interceptor - * @see - * LocaleChangeInterceptor - */ - @Bean - public LocaleChangeInterceptor localeChangeInterceptor() { - LocaleChangeInterceptor localeChangeInterceptor = new LocaleChangeInterceptor(); - localeChangeInterceptor.setParamName(DEFAULT_PARAM_NAME); - return localeChangeInterceptor; - } - - @Override - public void addInterceptors(InterceptorRegistry registry) { - // In order to take effect, this bean needs to be added to the application's interceptor registry. - registry.addInterceptor(localeChangeInterceptor()); - } }