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
参数就行了。