配置
只针对@RequestBody
@Bean
public Jackson2ObjectMapperBuilderCustomizer jackson2ObjectMapperBuilderCustomizer() {
return jacksonObjectMapperBuilder -> {
jacksonObjectMapperBuilder.deserializerByType(String.class, new StdScalarDeserializer<String>(String.class) {
@Override
public String deserialize(JsonParser jsonParser, DeserializationContext ctx)
throws IOException {
// 去除前后空格
return StrUtil.trim(jsonParser.getValueAsString());
}
});
};
}
标签:trim,String,jsonParser,jacksonObjectMapperBuilder,请求,public,springboot
From: https://www.cnblogs.com/ranger-dev/p/18091609