|
@ -1,13 +1,19 @@
|
|
|
package com.yihu.wlyy.config;
|
|
|
|
|
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.yihu.wlyy.interceptors.DoctorInterceptor;
|
|
|
import com.yihu.wlyy.interceptors.PatientInterceptor;
|
|
|
import com.yihu.wlyy.interceptors.UserInterceptor;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
import org.springframework.http.converter.HttpMessageConverter;
|
|
|
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
|
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
|
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* Created by chenweida on 2017/4/6.
|
|
|
*/
|
|
@ -31,4 +37,16 @@ public class MvcConfig extends WebMvcConfigurerAdapter {
|
|
|
super.addInterceptors(registry);
|
|
|
|
|
|
}
|
|
|
/**
|
|
|
* 为null的数据不返回
|
|
|
* @param converters
|
|
|
*/
|
|
|
@Override
|
|
|
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
|
|
|
MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter = new MappingJackson2HttpMessageConverter();
|
|
|
ObjectMapper objectMapper=new ObjectMapper();
|
|
|
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
|
|
mappingJackson2HttpMessageConverter.setObjectMapper(objectMapper);
|
|
|
converters.add(mappingJackson2HttpMessageConverter);
|
|
|
}
|
|
|
}
|