We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
后端fastjson统一转换器(统一格式化对象中的时间字段值),在1.2.83版本中有效,在2.0.49、2.0.50中无效。
有效时前端收到时间信息:“2024-05-14 21:31:10” 失效时前端收到时间信息:1715693470343
(部分关键源代码看下方)
请填写以下信息:
如何操作可以重现该问题:
import com.alibaba.fastjson.serializer.SerializerFeature; import com.alibaba.fastjson.support.config.FastJsonConfig; import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter; import com.yunhesoft.core.utils.AnnotationClassScanner; import com.yunhesoft.core.utils.StringUtils; import com.yunhesoft.system.auth.service.AuthService; import com.yunhesoft.system.kernel.settings.ConstSettings; import com.yunhesoft.system.kernel.settings.ConstSettingsInterface; import com.yunhesoft.system.tools.sysConfig.service.ISysConfigService; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import javax.servlet.MultipartConfigElement; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.web.servlet.MultipartConfigFactory; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.http.converter.HttpMessageConverter; import org.springframework.util.unit.DataSize; import org.springframework.web.servlet.config.annotation.CorsRegistry; import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; @Configuration public class Tm4WebMvcConfigurer implements WebMvcConfigurer { //... 非关键代码这里不列了 @Bean public HttpMessageConverter<?> fastJsonHttpMessageConverters() { FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter(); FastJsonConfig fastJsonConfig = new FastJsonConfig(); fastJsonConfig.setSerializerFeatures(new SerializerFeature[]{SerializerFeature.PrettyFormat, SerializerFeature.DisableCircularReferenceDetect, SerializerFeature.WriteMapNullValue}); fastJsonConfig.setDateFormat("yyyy-MM-dd HH:mm:ss"); fastConverter.setFastJsonConfig(fastJsonConfig); HttpMessageConverter<?> converter = fastConverter; return converter; } @Override public void configureMessageConverters(List<HttpMessageConverter<?>> converters) { converters.add(this.fastJsonHttpMessageConverters()); } }
在不使用字段注解与 JSON.toJSONString 方法的前提下使用 fastjson 转换器,能够正常执行 MVC 框架消息转换返回正确时间字符串给前端
JSON.toJSONString
无
The text was updated successfully, but these errors were encountered:
https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson/2.0.51-SNAPSHOT/ 问题已修复,请帮忙用2.0.51-SNAPSHOT版本验证下
Sorry, something went wrong.
fix FastJsonHttpMessageConverter dateFormat not work, for issue #2577
15362a0
https://github.com/alibaba/fastjson2/releases/tag/2.0.51 问题已修复,请用新版本
No branches or pull requests
问题描述
后端fastjson统一转换器(统一格式化对象中的时间字段值),在1.2.83版本中有效,在2.0.49、2.0.50中无效。
有效时前端收到时间信息:“2024-05-14 21:31:10”
失效时前端收到时间信息:1715693470343
(部分关键源代码看下方)
环境信息
请填写以下信息:
重现步骤
如何操作可以重现该问题:
期待的正确结果
在不使用字段注解与
JSON.toJSONString
方法的前提下使用 fastjson 转换器,能够正常执行 MVC 框架消息转换返回正确时间字符串给前端相关日志输出
无
附加信息
无
The text was updated successfully, but these errors were encountered: