From 999dfbf381c621c2b484d309534d5e279da87e0e Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Sat, 27 Jan 2018 17:43:23 +0200 Subject: [PATCH] remove enablemvc --- .../internationalization/config/MvcConfig.java | 4 +--- .../src/main/resources/static/internationalization.js | 8 ++++++++ .../src/main/resources/templates/international.html | 11 +---------- 3 files changed, 10 insertions(+), 13 deletions(-) create mode 100644 spring-boot/src/main/resources/static/internationalization.js diff --git a/spring-boot/src/main/java/com/baeldung/internationalization/config/MvcConfig.java b/spring-boot/src/main/java/com/baeldung/internationalization/config/MvcConfig.java index 59f7fd3ba5..478e8d393a 100644 --- a/spring-boot/src/main/java/com/baeldung/internationalization/config/MvcConfig.java +++ b/spring-boot/src/main/java/com/baeldung/internationalization/config/MvcConfig.java @@ -6,14 +6,12 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.LocaleResolver; -import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; import org.springframework.web.servlet.i18n.LocaleChangeInterceptor; import org.springframework.web.servlet.i18n.SessionLocaleResolver; @Configuration -@EnableWebMvc @ComponentScan(basePackages = "com.baeldung.internationalization.config") public class MvcConfig extends WebMvcConfigurerAdapter { @@ -33,6 +31,6 @@ public class MvcConfig extends WebMvcConfigurerAdapter { @Override public void addInterceptors(InterceptorRegistry registry) { - registry.addInterceptor(localeChangeInterceptor()); + registry.addInterceptor(localeChangeInterceptor()); } } diff --git a/spring-boot/src/main/resources/static/internationalization.js b/spring-boot/src/main/resources/static/internationalization.js new file mode 100644 index 0000000000..ae416f083d --- /dev/null +++ b/spring-boot/src/main/resources/static/internationalization.js @@ -0,0 +1,8 @@ +$(document).ready(function() { + $("#locales").change(function () { + var selectedOption = $('#locales').val(); + if (selectedOption != ''){ + window.location.replace('international?lang=' + selectedOption); + } + }); +}); \ No newline at end of file diff --git a/spring-boot/src/main/resources/templates/international.html b/spring-boot/src/main/resources/templates/international.html index a2a5fbb591..e0cfb5143b 100644 --- a/spring-boot/src/main/resources/templates/international.html +++ b/spring-boot/src/main/resources/templates/international.html @@ -4,16 +4,7 @@ Home - +