org.apache.catalina.connector.RequestFacade问题
org.apache.catalina.connector.RequestFacade cannot be cast to org.springframework.web.multipart.MultipartHttpServletRequest
这个错误怎么解决~
代码如下:
public String uploadfile(Map<String, Object> modelMap,
HttpServletRequest request, String documentDetails,String documentUploadingMan,
PlatformDocunment platformDocunment,String documentRemark) throws
IOException {
MultipartHttpServletRequest multipart = (MultipartHttpServletRequest) request;
MultipartFile file = multipart.getFile("file");
FileUtilImpl fileUpUtil = new FileUtilImpl();
String ext = fileUpUtil.getFileExt(file);
String outFileName = System.currentTimeMillis() + ext;
String dirFile = request.getSession().getServletContext()
.getRealPath("/resource/code/document");//code后加不加/都可以的
// URL relativepath = request.getSession().getServletContext()
// .getResource("/resource/code");
// String relativepathString = relativepath.getFile();
// String relativepathString2 = relativepath.getPath();
fileUpUtil
.upLoadFile(file.getInputStream(), dirFile, outFileName, null);
platformDocunment.setDocumentName(outFileName);
platformDocunment.setDocumentDetails(documentDetails);
platformDocunment.setDocumentUploadingTime(new Timestamp(System
.currentTimeMillis()));
platformDocunment.setDocumentUploadingMan(documentUploadingMan);
platformDocunment.setDocunmentStoreAddress("/resource/code/document/");
platformDocunment.setDocumentRemark(documentRemark);
Transaction transaction = platformImageDAO.getSession()
.beginTransaction();
platformDocunmentDAO.save(platformDocunment);
transaction.commit();
return "manager/success";
}
}
------最佳解决方案--------------------是类型转换错误,怎么解决我也不太清楚奥
------其他解决方案--------------------谢谢了,解决了,这个上传不需要经过后台,提交完成后,才经过后台,直接把页面提交就可以了,O(∩_∩)O~