小工具知识网

当前位置: 首页 > 行业知识 > 解决com.alibaba.fastjson.JSONException: write javaBean error, fastjson version 1.2.83

行业知识

解决com.alibaba.fastjson.JSONException: write javaBean error, fastjson version 1.2.83

2026-12-04 19:56:17 来源:互联网转载
2023-11-14 11:01:40.609  INFO 1 --- [nio-8083-exec-8] c.ai.sop.management.aop.ExceptionAspect:aroundAdvice常:com.alibaba.fastjson.JSONException: write javaBean error, fastjson version 1.2.83, class org.springframework.web.multipart.support.StandardMultipartHttpServletRequest, method : getAsyncContext

在日志中,Fastjson似乎试图将StandardMultipartHttpServletRequest序列化为JSON这可能是因为HttpServletRequest被错误地传递给了Fastjson,而不是MultipartFile

()

查看代码 

@RequestMapping(value = "/importInfoExcel")    public String importInfoExcel(HttpServletRequest httpServletRequest,HttpServletResponse httpServletResponse,MultipartFile multipartFile) {        String retmesg = "";        try {            logger.info("importInfoExcel-----");            EasyExcel.read(multipartFile.getInputStream(), OrgUser.class,new DataList(wlwService)).sheet().doRead();            retmesg = "{\"code\":1,\"desc\":\"导入完成\"}";            return retmesg;        } catch (Exception e) {            return "{\"code\":-1,\"desc\":\"导入失败\"}";        }

         看到问题可能出现在尝试将MultipartFile转换为JSON时具体来说,Fastjson库在尝试序列化HttpServletRequest对象时可能遇到了问题。要解决这个问题,需要确保只将MultipartFile对象传递给Fastjson。所以删除HttpServletRequest和HttpServletResponse参数就行了。

()

上一篇:Java微信小程序订阅消息提醒的实现与对接

下一篇:闲鱼怎么刷新服务器位置?