@@ -9,6 +9,7 @@ import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
@@ -20,7 +21,13 @@ public class JacksonConfig {
|
||||
@Bean
|
||||
@Primary
|
||||
public ObjectMapper objectMapper() {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
ObjectMapper mapper = Jackson2ObjectMapperBuilder.json()
|
||||
.defaultViewInclusion(true)
|
||||
.autoDetectFields(true)
|
||||
.failOnUnknownProperties(false)
|
||||
.featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
|
||||
.featuresToEnable(SerializationFeature.INDENT_OUTPUT)
|
||||
.build();
|
||||
|
||||
JavaTimeModule javaTimeModule = new JavaTimeModule();
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package ru.soune.nocopy.configuration;
|
||||
|
||||
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.web.filter.CharacterEncodingFilter;
|
||||
|
||||
@Configuration
|
||||
public class WebConfig {
|
||||
|
||||
@Bean
|
||||
public FilterRegistrationBean<CharacterEncodingFilter> characterEncodingFilter() {
|
||||
FilterRegistrationBean<CharacterEncodingFilter> filterRegBean = new FilterRegistrationBean<>();
|
||||
CharacterEncodingFilter filter = new CharacterEncodingFilter();
|
||||
filter.setEncoding("UTF-8");
|
||||
filter.setForceEncoding(true);
|
||||
filterRegBean.setFilter(filter);
|
||||
filterRegBean.addUrlPatterns("/*");
|
||||
filterRegBean.setOrder(Ordered.HIGHEST_PRECEDENCE);
|
||||
|
||||
return filterRegBean;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user