|
1 | | -package org.woehlke.simpleworklist.config; |
2 | | - |
3 | | -import org.springframework.context.MessageSource; |
4 | | -import org.springframework.context.annotation.Bean; |
5 | | -import org.springframework.context.annotation.Configuration; |
6 | | -import org.springframework.context.support.ResourceBundleMessageSource; |
7 | | -import org.springframework.data.web.config.EnableSpringDataWebSupport; |
8 | | -import org.springframework.validation.beanvalidation.MethodValidationPostProcessor; |
9 | | -import org.springframework.web.servlet.LocaleResolver; |
10 | | -import org.springframework.web.servlet.config.annotation.*; |
11 | | -import org.springframework.web.servlet.i18n.LocaleChangeInterceptor; |
12 | | -import org.springframework.web.servlet.i18n.SessionLocaleResolver; |
13 | | -import org.thymeleaf.dialect.springdata.SpringDataDialect; |
14 | | - |
15 | | -import java.util.Locale; |
16 | | - |
17 | | - |
18 | | -@Configuration |
19 | | -@EnableWebMvc |
20 | | -@EnableSpringDataWebSupport |
21 | | -public class WebMvcConfig extends WebMvcConfigurerAdapter implements WebMvcConfigurer { |
22 | | - |
23 | | - @Bean |
24 | | - public LocaleResolver localeResolver() { |
25 | | - SessionLocaleResolver slr = new SessionLocaleResolver(); |
26 | | - slr.setDefaultLocale(Locale.GERMANY); |
27 | | - return slr; |
28 | | - } |
29 | | - |
30 | | - @Bean |
31 | | - public LocaleChangeInterceptor localeChangeInterceptor() { |
32 | | - LocaleChangeInterceptor lci = new LocaleChangeInterceptor(); |
33 | | - lci.setParamName("lang"); |
34 | | - return lci; |
35 | | - } |
36 | | - |
37 | | - @Bean |
38 | | - public MessageSource messageSource(){ |
39 | | - ResourceBundleMessageSource x = new ResourceBundleMessageSource(); |
40 | | - x.setBasename("messages"); |
41 | | - return x; |
42 | | - } |
43 | | - |
44 | | - @Bean |
45 | | - public SpringDataDialect springDataDialect() { |
46 | | - return new SpringDataDialect(); |
47 | | - } |
48 | | - |
49 | | - @Bean |
50 | | - public MethodValidationPostProcessor methodValidationPostProcessor() { |
51 | | - return new MethodValidationPostProcessor(); |
52 | | - } |
53 | | - |
54 | | - public void addInterceptors(InterceptorRegistry registry) { |
55 | | - registry.addInterceptor(localeChangeInterceptor()); |
56 | | - } |
57 | | - |
58 | | - public void addViewControllers(ViewControllerRegistry registry) { |
59 | | - registry.addViewController("/").setViewName("redirect:/taskstate/inbox"); |
60 | | - registry.addViewController("/home").setViewName("redirect:/taskstate/inbox"); |
61 | | - } |
62 | | - |
63 | | - public void addResourceHandlers(ResourceHandlerRegistry registry) { |
64 | | - registry.addResourceHandler("/css/*").addResourceLocations("classpath:/static/css/"); |
65 | | - registry.addResourceHandler("/css/**").addResourceLocations("classpath:/static/css/"); |
66 | | - registry.addResourceHandler("/img/*").addResourceLocations("classpath:/static/img/"); |
67 | | - registry.addResourceHandler("/img/**").addResourceLocations("classpath:/static/img/"); |
68 | | - registry.addResourceHandler("/js/*").addResourceLocations("classpath:/static/js/"); |
69 | | - registry.addResourceHandler("/js/**").addResourceLocations("classpath:/static/js/"); |
70 | | - registry.addResourceHandler("/webjars/*").addResourceLocations("/webjars/"); |
71 | | - registry.addResourceHandler("/webjars/**").addResourceLocations("/webjars/"); |
72 | | - } |
73 | | -} |
| 1 | +package org.woehlke.simpleworklist.config.di; |
| 2 | + |
| 3 | +import org.springframework.context.MessageSource; |
| 4 | +import org.springframework.context.annotation.Bean; |
| 5 | +import org.springframework.context.annotation.Configuration; |
| 6 | +import org.springframework.context.support.ResourceBundleMessageSource; |
| 7 | +import org.springframework.data.web.config.EnableSpringDataWebSupport; |
| 8 | +import org.springframework.validation.beanvalidation.MethodValidationPostProcessor; |
| 9 | +import org.springframework.web.servlet.LocaleResolver; |
| 10 | +import org.springframework.web.servlet.config.annotation.*; |
| 11 | +import org.springframework.web.servlet.i18n.LocaleChangeInterceptor; |
| 12 | +import org.springframework.web.servlet.i18n.SessionLocaleResolver; |
| 13 | +import org.thymeleaf.dialect.springdata.SpringDataDialect; |
| 14 | + |
| 15 | +import java.util.Locale; |
| 16 | + |
| 17 | + |
| 18 | +@Configuration |
| 19 | +@EnableWebMvc |
| 20 | +@EnableSpringDataWebSupport |
| 21 | +public class WebMvcConfig extends WebMvcConfigurerAdapter implements WebMvcConfigurer { |
| 22 | + |
| 23 | + @Bean |
| 24 | + public LocaleResolver localeResolver() { |
| 25 | + SessionLocaleResolver slr = new SessionLocaleResolver(); |
| 26 | + slr.setDefaultLocale(Locale.GERMANY); |
| 27 | + return slr; |
| 28 | + } |
| 29 | + |
| 30 | + @Bean |
| 31 | + public LocaleChangeInterceptor localeChangeInterceptor() { |
| 32 | + LocaleChangeInterceptor lci = new LocaleChangeInterceptor(); |
| 33 | + lci.setParamName("lang"); |
| 34 | + return lci; |
| 35 | + } |
| 36 | + |
| 37 | + @Bean |
| 38 | + public MessageSource messageSource(){ |
| 39 | + ResourceBundleMessageSource x = new ResourceBundleMessageSource(); |
| 40 | + x.setBasename("messages"); |
| 41 | + return x; |
| 42 | + } |
| 43 | + |
| 44 | + @Bean |
| 45 | + public SpringDataDialect springDataDialect() { |
| 46 | + return new SpringDataDialect(); |
| 47 | + } |
| 48 | + |
| 49 | + @Bean |
| 50 | + public MethodValidationPostProcessor methodValidationPostProcessor() { |
| 51 | + return new MethodValidationPostProcessor(); |
| 52 | + } |
| 53 | + |
| 54 | + public void addInterceptors(InterceptorRegistry registry) { |
| 55 | + registry.addInterceptor(localeChangeInterceptor()); |
| 56 | + } |
| 57 | + |
| 58 | + public void addViewControllers(ViewControllerRegistry registry) { |
| 59 | + registry.addViewController("/").setViewName("redirect:/taskstate/inbox"); |
| 60 | + registry.addViewController("/home").setViewName("redirect:/taskstate/inbox"); |
| 61 | + } |
| 62 | + |
| 63 | + public void addResourceHandlers(ResourceHandlerRegistry registry) { |
| 64 | + registry.addResourceHandler("/css/*").addResourceLocations("classpath:/static/css/"); |
| 65 | + registry.addResourceHandler("/css/**").addResourceLocations("classpath:/static/css/"); |
| 66 | + registry.addResourceHandler("/img/*").addResourceLocations("classpath:/static/img/"); |
| 67 | + registry.addResourceHandler("/img/**").addResourceLocations("classpath:/static/img/"); |
| 68 | + registry.addResourceHandler("/js/*").addResourceLocations("classpath:/static/js/"); |
| 69 | + registry.addResourceHandler("/js/**").addResourceLocations("classpath:/static/js/"); |
| 70 | + registry.addResourceHandler("/webjars/*").addResourceLocations("/webjars/"); |
| 71 | + registry.addResourceHandler("/webjars/**").addResourceLocations("/webjars/"); |
| 72 | + } |
| 73 | +} |
0 commit comments