java.lang.ClassCastException: org.apache.shiro.web.servlet.ShiroHttpServletRequest cannot be cast to

今天在做上传的时候,遇到一个这亲的问题。如题目。

以为是配置文件这与错了。结果查看了好长时间,没找一以错。程序里也没有问题。

最后,问题出在了jquery validate 验证这里。只好改成在form里提交。

如下:

导入
添加Excel文件 *



@RequestMapping("getUpLoadFile")
	@SuppressWarnings({"unchecked","rawtypes"})
	public void getUpLoadFile(HttpServletRequest request, HttpServletResponse response) throws IOException{
		
		MultipartHttpServletRequest multipartRequest =  (MultipartHttpServletRequest) request;  
        Map fileMap = multipartRequest.getFileMap();      
        String ctxPath=request.getSession().getServletContext().getRealPath("/")+"fileUpload"; //文件上传存储路径 
        ctxPath +=  File.separator;    
        // 创建文件夹    
        File file = new File(ctxPath);      
        if (!file.exists()) {      
        file.mkdirs();      
        }  
        String fileName = null;   
        String newName = null;  
        for (Map.Entry entity : fileMap.entrySet()) {      
	        // 上传文件     
	        MultipartFile mf = entity.getValue();    
	        fileName = mf.getOriginalFilename();//获取原文件名  
	        //获得当前时间的最小精度  
	        SimpleDateFormat format =  new SimpleDateFormat("yyyyMMddHHmmssSSS");  
	        newName = format.format(new Date());  
	        //获得三位随机数  
	        Random random = new Random();  
	        for(int i = 0; i < 3; i++){  
	            newName = newName + random.nextInt(9);  
	        }  
	        File uploadFile = new File(ctxPath + newName+fileName.substring(fileName.lastIndexOf(".")));  
	       try {    
	        FileCopyUtils.copy(mf.getBytes(), uploadFile);   
	       } catch (IOException e){  
	             e.printStackTrace();    
	       }  
       }  
        response.setHeader("Content-type", "text/html;charset=UTF-8");  
        response.setCharacterEncoding("UTF-8");  
       // response.getWriter().write(newName+fileName.substring(fileName.lastIndexOf("."))); 
        //处理上传数据
        try {
        	
        	String importFile = ctxPath + newName+fileName.substring(fileName.lastIndexOf("."));
        	importFile = importFile.replaceAll("\\\\","/");
        				
        	response.getWriter().write(""); //这里设置是返回时的处理方法。直接在js写function upLoadFinsh(){}就行
		} catch (Exception e) {
			logger.error("保存失败", e);
		}
	}



你可能感兴趣的:(java.lang.ClassCastException: org.apache.shiro.web.servlet.ShiroHttpServletRequest cannot be cast to)