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
查看代码 文章来源:https://www.toymoban.com/news/detail-770960.html
@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
参数就行了。文章来源地址https://www.toymoban.com/news/detail-770960.html
到了这里,关于解决com.alibaba.fastjson.JSONException: write javaBean error, fastjson version 1.2.83的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!