| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.web.config;
|
1 |
package com.spice.profitmandi.web.config;
|
| 2 |
|
2 |
|
| - |
|
3 |
import java.util.List;
|
| - |
|
4 |
|
| 3 |
import org.springframework.beans.factory.annotation.Autowired;
|
5 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 4 |
import org.springframework.context.annotation.ComponentScan;
|
6 |
import org.springframework.context.annotation.ComponentScan;
|
| 5 |
import org.springframework.context.annotation.Configuration;
|
7 |
import org.springframework.context.annotation.Configuration;
|
| - |
|
8 |
import org.springframework.http.converter.HttpMessageConverter;
|
| - |
|
9 |
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
| 6 |
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
10 |
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
| 7 |
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
11 |
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
| 8 |
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
12 |
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
| 9 |
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
13 |
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
| 10 |
|
14 |
|
| - |
|
15 |
import com.fasterxml.jackson.databind.ObjectMapper;
|
| - |
|
16 |
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
|
| - |
|
17 |
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
| - |
|
18 |
import com.fasterxml.jackson.module.paramnames.ParameterNamesModule;
|
| 11 |
import com.spice.profitmandi.web.interceptor.AuthenticationInterceptor;
|
19 |
import com.spice.profitmandi.web.interceptor.AuthenticationInterceptor;
|
| 12 |
import com.spice.profitmandi.web.interceptor.RoleInterceptor;
|
20 |
import com.spice.profitmandi.web.interceptor.RoleInterceptor;
|
| 13 |
|
21 |
|
| 14 |
@EnableWebMvc
|
22 |
@EnableWebMvc
|
| 15 |
@Configuration
|
23 |
@Configuration
|
| Line 34... |
Line 42... |
| 34 |
public void addInterceptors(InterceptorRegistry registry) {
|
42 |
public void addInterceptors(InterceptorRegistry registry) {
|
| 35 |
registry.addInterceptor(authenticationInterceptor).addPathPatterns("/**").excludePathPatterns("/login", "/login/", "/", "");
|
43 |
registry.addInterceptor(authenticationInterceptor).addPathPatterns("/**").excludePathPatterns("/login", "/login/", "/", "");
|
| 36 |
registry.addInterceptor(roleInterceptor).excludePathPatterns("/login", "/login/", "/register", "/register/", "", "/");
|
44 |
registry.addInterceptor(roleInterceptor).excludePathPatterns("/login", "/login/", "/register", "/register/", "", "/");
|
| 37 |
}
|
45 |
}
|
| 38 |
|
46 |
|
| - |
|
47 |
|
| - |
|
48 |
@Override
|
| - |
|
49 |
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
|
| - |
|
50 |
|
| - |
|
51 |
converters.add(new MappingJackson2HttpMessageConverter(objectMapper()));
|
| - |
|
52 |
super.configureMessageConverters(converters);
|
| - |
|
53 |
}
|
| - |
|
54 |
|
| - |
|
55 |
private ObjectMapper objectMapper() {
|
| - |
|
56 |
ObjectMapper mapper = new ObjectMapper()
|
| - |
|
57 |
.registerModule(new ParameterNamesModule())
|
| - |
|
58 |
.registerModule(new Jdk8Module())
|
| - |
|
59 |
.registerModule(new JavaTimeModule()); // new module, NOT JSR310Module
|
| - |
|
60 |
return mapper;
|
| - |
|
61 |
}
|
| - |
|
62 |
|
| 39 |
}
|
63 |
}
|