求助 java 导入Excel日志本地可以 服务器报错
源代码 
服务器报错 jxl.read.biff.biffexception: the input file was not found
private String importUserlog(HttpServletRequest request,Parameters params) throws Exception{
    String userName = ((Parameters) (request.getSession().getAttribute("_current"))).getString("managerName");
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
    MultipartFile excelFile = multipartRequest.getFile("Filedata"); 
    //String tempPath = request.getSession().getServletContext().getRealPath("/")+"/template/"+"rzgl/"+"viewJournal/"+"userlog.xls";//未加密前的文件
    //File tempPath = new File(request.getSession().getServletContext().getRealPath("/")+"//template//rzgl//viewJournal//userlog.xls");
    File tempPath1 = new File(request.getSession().getServletContext().getRealPath("/")+"/template/rzgl/viewJournal/userlog.xls");
    System.out.println(tempPath1+"-------------------用户日志导入");
    if(tempPath1.exists()&&tempPath1.length()>0)
        tempPath1.delete();
    FileUtils.copyInputStreamToFile(excelFile.getInputStream(), tempPath1);
    if(!tempPath1.exists()){
        request.setAttribute("error", "文件不存在!");
        return "rzgl/viewJournal/upload";
    }
    Workbook book = Workbook.getWorkbook(tempPath1);
    Sheet sheet = book.getSheet(0);
    int num=0;
    for(int i = 1; i < sheet.getRows(); i ++){
        Loginfo info = new Loginfo();
        if(sheet.getCell(0, i).getContents().trim().equals("")&&sheet.getCell(1, i).getContents().trim().equals("")&&sheet.getCell(2, i).getContents().trim().equals("")){
            continue;
        }
        info.setLoginName(sheet.getCell(0, i).getContents().trim());
        info.setLogTime(sheet.getCell(1, i).getContents().trim());
        info.setLogIp(sheet.getCell(2, i).getContents().trim());
        info.setLogInfo(sheet.getCell(3, i).getContents().trim());
        info.setActionObject(sheet.getCell(4, i).getContents().trim());
        info.setActionType(sheet.getCell(5, i).getContents().trim());
        info.setTerminal(sheet.getCell(6, i).getContents().trim());
        info.setStauts("1");
        try{
            int temp = logService.addUserInfo(info);
            if(temp>0)
                num++;
        }catch(Exception e){

            e.printStackTrace();
        }
    }
    int err = sheet.getRows()-num-1;
    if(tempPath1.exists())tempPath1.delete();//删除解密前的原文件
    this.tempsuccess = num;
    this.temperror = err;
    book.close();
    Manager user = new Manager();
    user.setLoginName(userName);
    user.setLogIp(request.getRemoteAddr());
    user.setLogInfo(userName+"导入用户日志:成功"+num+"条,失败"+err+"条");
    user.setObjectId("用户日志");
    user.setActionType("导入");
    recordService.addRecord(user);
    return helper(request,num,err);


    看了网上了 没解决

2个回答

路径不对吧,看看路径

@yuefeng1110 导入的时候服务器上创建了userlog这个文件 但是这个文件里面的数据为0

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问