//获取WebContent中的图片和附件Documentdoc=Jsoup.parse(info.getWebc().getWebContent());//当前页面中的图片ElementssrcLinks=doc.select("img[src]");StringimagesPath="";for(Elementlink:srcLinks){//去掉标签,只留下链接路径StringimagesPaths=link.attr("src");Stringht=imagesPaths.substring(0,4);Stringhtt=imagesPaths.substring(0,1);if(!ht.equals("http")&&htt.equals("/")){imagesPath=imagesPaths.trim().replaceAll(ContextPath,"");imagesPath=imagesPath.substring(imagesPath.lastIndexOf("/")+1);}else{imagesPath="";}//System.out.println("---在WebContent中导入图片---"+imagesPath);if(!imagesPath.equals("")){importCopy("/html/"+strSiteID+"/"+strColumnID+"/"+keyID+"/"+imagesPath,path,strInfoID,"/html/"+strSiteID+"/"+strColumnID+"/"+keyID+"/");}}//提取所有href连接StringfilePaths="";Elementslinehrefs=doc.select("t;a[href]");for(Elementlink:linehrefs){filePaths=link.attr("href").trim().replaceAll(ContextPath,"");filePaths=filePaths.substring(filePaths.lastIndexOf("/")+1);//System.out.println("---在WebContent中导入文件---"+filePaths);if(!filePaths.equals("")){importCopy("/html/"+strSiteID+"/"+strColumnID+"/"+keyID+"/"+filePaths,path,strInfoID,"/html/"+strSiteID+"/"+strColumnID+"/"+keyID+"/");}}【本文为专栏作家张永波原创文章,转载请征得作者授权】
