Commit 6f3a26a8 by 墨竹

feat:前端丢失精度问题

parent 744e0ee4
package com.gic.haoban.manage.web.config;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
/**
* Created 2021/12/23.
*
* @author hua
*/
public class LongHttpMessageConverter extends MappingJackson2HttpMessageConverter {
public LongHttpMessageConverter() {
super();
//修复:前端js 精度问题
ObjectMapper objectMapper = getObjectMapper();
SimpleModule simpleModule = new SimpleModule();
simpleModule.addSerializer(Long.class, ToStringSerializer.instance);
simpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance);
objectMapper.registerModule(simpleModule);
setObjectMapper(objectMapper);
}
}
...@@ -30,12 +30,13 @@ ...@@ -30,12 +30,13 @@
<mvc:annotation-driven> <mvc:annotation-driven>
<!-- 设置不使用默认的消息转换器 --> <!-- 设置不使用默认的消息转换器 -->
<mvc:message-converters register-defaults="false"> <mvc:message-converters register-defaults="false">
<bean class="com.gic.haoban.manage.web.config.LongHttpMessageConverter"/>
<bean class="com.gic.haoban.common.ext.MappingJackson2HttpMessagePropertyViewConverter"/> <bean class="com.gic.haoban.common.ext.MappingJackson2HttpMessagePropertyViewConverter"/>
<bean class="org.springframework.http.converter.StringHttpMessageConverter"> <bean class="org.springframework.http.converter.StringHttpMessageConverter">
<property name="supportedMediaTypes"> <property name="supportedMediaTypes">
<list> <list>
<value>text/html;charset=UTF-8</value> <value>text/html;charset=UTF-8</value>
<value>application/x-www-form-urlencoded;charset=UTF-8</value> <value>application/x-www-form-urlencoded;charset=UTF-8</value>
<!--默认是 iso-8859-1 --> <!--默认是 iso-8859-1 -->
</list> </list>
</property> </property>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment