File tree Expand file tree Collapse file tree
java/com/baeldung/internationalization/config Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66import org .springframework .context .annotation .ComponentScan ;
77import org .springframework .context .annotation .Configuration ;
88import org .springframework .web .servlet .LocaleResolver ;
9- import org .springframework .web .servlet .config .annotation .EnableWebMvc ;
109import org .springframework .web .servlet .config .annotation .InterceptorRegistry ;
1110import org .springframework .web .servlet .config .annotation .WebMvcConfigurerAdapter ;
1211import org .springframework .web .servlet .i18n .LocaleChangeInterceptor ;
1312import org .springframework .web .servlet .i18n .SessionLocaleResolver ;
1413
1514@ Configuration
16- @ EnableWebMvc
1715@ ComponentScan (basePackages = "com.baeldung.internationalization.config" )
1816public class MvcConfig extends WebMvcConfigurerAdapter {
1917
@@ -33,6 +31,6 @@ public LocaleChangeInterceptor localeChangeInterceptor() {
3331
3432 @ Override
3533 public void addInterceptors (InterceptorRegistry registry ) {
36- registry .addInterceptor (localeChangeInterceptor ());
34+ registry .addInterceptor (localeChangeInterceptor ());
3735 }
3836}
Original file line number Diff line number Diff line change 1+ $ ( document ) . ready ( function ( ) {
2+ $ ( "#locales" ) . change ( function ( ) {
3+ var selectedOption = $ ( '#locales' ) . val ( ) ;
4+ if ( selectedOption != '' ) {
5+ window . location . replace ( 'international?lang=' + selectedOption ) ;
6+ }
7+ } ) ;
8+ } ) ;
Original file line number Diff line number Diff line change 44< meta charset ="ISO-8859-1 " />
55< title > Home</ title >
66< script src ="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js "> </ script >
7- < script type ="text/javascript ">
8- $ ( document ) . ready ( function ( ) {
9- $ ( "#locales" ) . change ( function ( ) {
10- var selectedOption = $ ( '#locales' ) . val ( ) ;
11- if ( selectedOption != '' ) {
12- window . location . replace ( 'international?lang=' + selectedOption ) ;
13- }
14- } ) ;
15- } ) ;
16- </ script >
7+ < script src ="internationalization.js "> </ script >
178</ head >
189< body >
1910< h1 th:text ="#{greeting} "> </ h1 >
You can’t perform that action at this time.
0 commit comments