文件类型转换错误cannot be cast to org.springframework.web.multipart.MultipartHttpServletRequest

org.apache.shiro.web.servlet.ShiroHttpServletRequest cannot be cast to org.springframework.web.multipart.MultipartHttpServletRequest文件类型转换错误

文件类型转换错误

原文请移步

 MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest)(request);

空文件上传会出现类型转换错误
做一步处理

MultipartHttpServletRequest multipartRequest =null;
if (request instanceof MultipartHttpServletRequest) {
multipartRequest = (MultipartHttpServletRequest)(request);
}

先判断httpRequest 是否含有文件类型 ,若含文件,则将httpRequest 转换为MultipartHttpServletRequest类型。

相关推荐
©️2020 CSDN 皮肤主题: 游动-白 设计师:白松林 返回首页