All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.base4j.mvc.conf.JsonConfig Maven / Gradle / Ivy

There is a newer version: 1.3.0
Show newest version
package com.base4j.mvc.conf;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import java.util.Arrays;
import java.util.List;

@Configuration
public class JsonConfig extends WebMvcConfigurerAdapter {
    
    @Override
    public void configureMessageConverters(List> converters) {
        converters.add(mappingJackson2HttpMessageConverter());
    }
    
    @Bean
    public MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter() {
        MappingJackson2HttpMessageConverter ret = new MappingJackson2HttpMessageConverter();
        ret.setSupportedMediaTypes(Arrays.asList(MediaType.APPLICATION_JSON, MediaType.TEXT_HTML));
        ret.setObjectMapper(new JacksonCustomObjectMapper());
        return ret;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy