開發(fā)文件列表顯示功能_第1頁(yè)
開發(fā)文件列表顯示功能_第2頁(yè)
開發(fā)文件列表顯示功能_第3頁(yè)
開發(fā)文件列表顯示功能_第4頁(yè)
開發(fā)文件列表顯示功能_第5頁(yè)
已閱讀5頁(yè),還剩9頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

開發(fā)文件列表功能一、目錄21.技術(shù)原理2.效果圖預(yù)覽3.實(shí)現(xiàn)步驟4.功能驗(yàn)證測(cè)試二、技術(shù)原理3(1)視圖層:展示所有文件信息(2)控制層:接收視圖層的消息,向服務(wù)層發(fā)送文件列表參數(shù),并將服務(wù)層返回的結(jié)果發(fā)送到視圖層(3)服務(wù)層:獲取當(dāng)前賬號(hào)的云存儲(chǔ)對(duì)象,將獲取到的云存儲(chǔ)對(duì)象轉(zhuǎn)換為本地模擬文件系統(tǒng)4三、效果預(yù)覽圖5在cn/edu/sict/cloud/storage/sh/bean文件夾下創(chuàng)建FileBean.javapublic

classFileBean{private

boolean

isdirectory;//是否是目錄private

boolean

haschild;//是否有子文件夾privateStringname;//文件名稱privateStringpath;//文件路徑privateStringlength;//文件大小privateStringlastmodified;//最后修改時(shí)間privateStringfilepath;//如果是文件,存放文件的臨時(shí)路徑public

booleanisHaschild(){return

haschild;}public

voidsetHaschild(boolean

haschild){this.haschild=haschild;}public

booleanisIsdirectory(){return

isdirectory;}public

voidsetIsdirectory(boolean

isdirectory){this.isdirectory=isdirectory;}publicStringgetFilepath(){return

filepath;}public

voidsetFilepath(Stringfilepath){this.filepath=filepath;}publicStringgetLength(){return

length;}public

voidsetLength(long

length){this.length=UtilTools.convertFileSize(length);}publicStringgetLastmodified(){return

lastmodified;}public

voidsetLastmodified(Stringlastmodified){this.lastmodified=lastmodified;}publicStringgetName(){return

name;}public

voidsetName(Stringname){=name;}publicStringgetPath(){return

path;}public

voidsetPath(Stringpath){this.path=path;}四、步驟實(shí)現(xiàn)6在cn/edu/sict/cloud/storage/sh/文件夾下swiftDFS.java添加如下代碼publicListgetFile(Stringrpath){Mapmappath=this.getSplitPath(rpath);StringrootPath=mappath.get("rootPath").toString();Stringpath=mappath.get("path").toString();List<?extendsSwiftObject>objs=this.list(rootPath,path);Listlist=newArrayList();for(SwiftObjectobj:objs){FileBeanfb=newFileBean();StringfilePath=obj.getName();fb.setPath(filePath);fb.setName(this.getName(filePath));boolean

flag=this.isDirectory(filePath);fb.setIsdirectory(flag);if(!flag){fb.setLength(obj.getSizeInBytes());}fb.setLastmodified(DateUtil.cstToHMS(obj.getLastModified()));list.add(fb);}return

list;}四、步驟實(shí)現(xiàn)7在cn/edu/sict/cloud/storage/sh/文件夾下swiftDFS.java添加如下代碼privateMap<String,String>getSplitPath(Stringpath){String[]strPath=path.split("/");StringrootPath="";path="";for(int

i=0;i<strPath.length;i++){if(i==0){rootPath=strPath[0];}else{if(i==strPath.length-1){if(strPath[i].contains(".")){path+=strPath[i];}else{path+=strPath[i]+"/";}}else{path+=strPath[i]+"/";}}}Mapmap=newHashMap();map.put("rootPath",rootPath);map.put("path",path);return

map;}四、步驟實(shí)現(xiàn)8在cn/edu/sict/cloud/storage/util文件夾下新建ComparatorFile.javapublic

classComparatorFileimplementsComparator<FileBean>{publicComparatorFile(){}public

intcompare(FileBeanf1,FileBeanf2){boolean

f1dir=f1.isIsdirectory();boolean

f2dir=f2.isIsdirectory();if(f1dir&&f2dir){return0;}else

if(!f1dir&&f2dir){return1;}else

if(f1dir&&!f2dir){return-1;}else

if(!f1dir&&!f2dir){return0;}return0;}}四、步驟實(shí)現(xiàn)9在cn/edu/sict/cloud/storage/service/SwiftStorageService.java添加如下代碼publicListgetAllStoredList(Stringusername,Stringpath){SwiftDFSswiftdfs=newSwiftDFS();Stringup=null;up=username+"/"+path;Listlist=swiftdfs.getFile(up);ComparatorFilecomparator=newComparatorFile();

if(!list.isEmpty()){

synchronized(list){Collections.sort(list,comparator);

}

}return

list;}四、步驟實(shí)現(xiàn)10在cn/edu/sict/cloud/storage/Web/StorageController.java添加如下代碼@RequestMapping("/home")publicModelAndViewhome(HttpServletRequestrequest,HttpServletResponseresponse,Stringpath){ModelAndViewview=newModelAndView();Useruser=getSessionUser(request);path=UtilTools.converStr(path);Listlist=storage.getAllStoredList(user.getUsername(),path);view.addObject("path",path);view.addObject("search","false");view.addObject("list",list);view.setViewName("/main");view.addObject("type",0);return

view;}四、步驟實(shí)現(xiàn)11在main.jsp的table標(biāo)簽中添加如下代碼<tbodyid="tab"><c:forEachvar="fb"items="${list}"><tr><tdstyle="top:-6px;position:relative;left:13px;"><labelclass="checkboxtable-checkboxposition"for="checkbox1"><spanclass="iconsmain-icons">

<spanclass="first-iconfui-checkbox-unchecked"></span>

<spanclass="second-iconfui-checkbox-checked"></span></span>

<inputtype="checkbox"name='check'class="main-tabinput"onclick="show()"></label></td><td><spanstyle="display:block"><c:iftest="${fb.isdirectory==true}"><imgsrc="assets/images/0.png"class="objimg"><a

href="home.action?path=${fb.path}"><inputname="objimg"type="text"style="display:none"value="${}"></c:if>${}<c:iftest="${fb.isdirectory==true}"></a>四、步驟實(shí)現(xiàn)12在main.jsp的table標(biāo)簽中添加如下代碼</c:if></span><divclass="edit-name"style="display:none;"><inputclass="box"type="text"value="${}"><aclass="sure

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論