一、该问题的重现步骤是什么?
用的springboot版本,4.0.1版本
请问下如何在框架层面去除数值类字段小数点后面多余的0。
之前自己用springboot都是照网上的办法,如下:
@Configuration public class JacksonConfig { @Bean public ObjectMapper objectMapper() { ObjectMapper objectMapper = new ObjectMapper(); SimpleModule module = new SimpleModule(); module.addSerializer(BigDecimal.class, new JsonSerializer<BigDecimal>() { @Override public void serialize(BigDecimal value, JsonGenerator gen, SerializerProvider serializers) throws IOException { if (value != null) { gen.writeString(value.stripTrailingZeros().toPlainString()); } } }); objectMapper.registerModule(module); return objectMapper; }}
但是现在加这样一个类后,日期类字段会变成一个字符串,反而数值的字段没有变化
二、你期待的结果是什么?实际看到的又是什么?
三、你正在使用的是什么产品,什么版本?在什么操作系统上?
四、请提供详细的错误堆栈信息,这很重要。
五、若有更多详细信息,请在下面提供。
- 热议问题
-
验证码如何限制只有数字
1
-
组态数据过滤器data显示为null
1
-
cloud项目运行启动报错
1
-
物联网平台的防注入代码在哪
1
-
漏洞:越权
2
-
升级最新版代码后,使用代码生成功能报错
1
-
broker模块如何设置用mqtt协议连接
1
-
saber3 4.6版本无法启动问题
1
-
物理模型设置参数时操作失败,如何设置监听topic?
1
-
nacos 配置两个数据源,我在项目引入最新的redis配置 但是不生效;请问什么原因;
2
扫一扫访问 Blade技术社区 移动端