sx:tree 标签生成树状的文件列表
来源:互联网 发布:搜索引擎数据库设计 编辑:程序博客网 时间:2024/04/30 13:29
</pre>参照 Java Web 开发实战1200例写的一个将HDFS文件以树状形式展示的文件列表</p><p>因为是为了复制和移动的功能写的,故只显示文件夹</p><p>点击确定会在文本框中显示选择文件的路径</p><pre name="code" class="java">package com.suiyue;import java.io.IOException;import java.util.ArrayList;import java.util.List;import org.apache.hadoop.conf.Configuration;import org.apache.hadoop.fs.FileStatus;import org.apache.hadoop.fs.FileSystem;import org.apache.hadoop.fs.Path;public class HdfsList {private FileSystem fileSystem;private FileStatus fileStatus;private String hdfsFileName;public String getHdfsFileName() {return hdfsFileName;}public void setHdfsFileName(String hdfsFileName) {this.hdfsFileName = hdfsFileName;}private List list = new ArrayList();private String hdfsPath;public String getHdfsPath() {return hdfsPath;}public void setHdfsPath(String hdfsPath) {this.hdfsPath = hdfsPath;}public FileSystem getFileSystem() {return fileSystem;}public void setFileSystem(FileSystem fileSystem) {this.fileSystem = fileSystem;}public FileStatus getFileStatus() {return fileStatus;}public void setFileStatus(FileStatus fileStatus) {this.fileStatus = fileStatus;}public List getList() {return list;}public void setList(List list) {this.list = list;}public static String HdfsPath() {return "hdfs://localhost:9001/user";}public HdfsList(String hdfsPath){this.hdfsPath = hdfsPath;Path path = new Path(hdfsPath);this.hdfsFileName = path.getName();Configuration conf = new Configuration();FileSystem fs;try {fs = FileSystem.get(conf);FileStatus[] files = fs.listStatus(path);for(int i=0; i<files.length;i++) {if(files[i].isDir()) {HdfsList hdfslist = new HdfsList(files[i].getPath().toString() + "/");list.add(hdfslist);} }} catch (IOException e) {// TODO Auto-generated catch blocke.printStackTrace();}}}
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"import = "com.suiyue.HdfsList"import = "org.apache.hadoop.fs.*"%><%@ taglib uri="/struts-tags" prefix="s"%><%@ taglib prefix="sx" uri="/struts-dojo-tags"%> <%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head> <base href="<%=basePath%>"> <title>My JSP 'index.jsp' starting page</title><meta http-equiv="pragma" content="no-cache"><meta http-equiv="cache-control" content="no-cache"><meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"><meta http-equiv="description" content="This is my page"><!--<link rel="stylesheet" type="text/css" href="styles.css">--><s:head /><sx:head parseContent="true"/><script type="text/javascript"> function treeNodeSelected(arg) { var input = document.getElementById("filepath"); var s = dojo.widget.byId('root').selector; //alert(s.selectedNode.widgetId); input.value = s.selectedNode.widgetId; //alert(arg.source.widgetId + ' selected'); //return arg.source.widgetId; } dojo.addOnLoad(function() { var s = dojo.widget.byId('root').selector; dojo.event.connect(s, 'select', 'treeNodeSelected'); }); </script> </head> <body> 文件列表: <% request.setAttribute("file", new HdfsList(HdfsList.HdfsPath())); %> <s:set name="k" value="0"></s:set> <sx:tree id="root" rootNode="%{#request.file}" nodeTitleProperty="hdfsFileName" nodeIdProperty="hdfsPath" childCollectionProperty="list" > </sx:tree> <button name="submit" onclick="treeNodeSelected()">确定</button> <input type="text" id="filepath" value=""> </body></html>
0 0
- sx:tree 标签生成树状的文件列表
- <sx:tree><sx:tree>树状菜单
- 利用Tree命令生成磁盘文件列表
- 利用Tree命令生成磁盘文件列表
- Android中的树状(tree)列表
- Android中的树状(tree)列表
- android tree树状列表+checkbox
- struts2标签sx:datetimepicker报错异常的解决方法
- Leetcode-标签为Tree的easy题目列表
- sx:datetimepicker的使用
- sx
- struts 2.1.8.1的sx:datetimepicker标签出现NaN错误的原因和解决办法
- struts2中日期标签的<sx:datatimepicker>的使用
- struts 2.1.8.1的sx:datetimepicker标签出现NaN错误的原因和解决办法
- Struts使用dojo框架的 AJAX标签中的<sx:head/>的作用
- 关于struts2中sx:datetimepicker标签月份正常显示的解决方法
- python把生成的图像文本列表加标签
- 生成树状菜单(ul-li) 及其 树状下拉列表框
- Netty4详解二:开发第一个Netty应用程序
- SQLServer 数据加密解密:将 TDE 保护的数据库移到其他实例(二)
- wireshark中tcpdump过滤方法详解
- Lua_table中常用的四种遍历方式
- 2-3
- sx:tree 标签生成树状的文件列表
- 山东第四届省赛 I (基础类)
- 4.7-ANDROID面试
- CUDA Toolkit v7.0最新技术文档合集
- iOS企业账号发布流程
- Windows上SSH服务器的配置以及客户端的连接
- C++对象向基本类型转换
- Jpexs分析
- NSRunLoop和nstimer