jsp如何读取服务器指定目录结构 如题,请大哥们说说思路或展示下代码, 不胜感激 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 jsp读取跟java读取不是一样的么?如果java读取会的话,jsp也就行了。无非就是给个路径,然后用流进行读取。 java读取目录结构不是很难,File类http://edu.codepub.com/2009/0721/10530.php 就用File类啊,不是一样的读嘛?<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%><%@ page import="java.io.File"%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><% String url = request.getRequestURL().toString(); String path = url.substring(0, url.lastIndexOf("/")); String mainPath = path.substring(0, path.lastIndexOf("/")); String msg = request.getParameter("msg"); if (msg == null) { msg = ""; } String savePath = this.getServletContext().getRealPath("/") + "testcase"; System.out.println(savePath); //看看取到的哪个目录? String[] testCaseLst = null; String existName = ""; File dir = new File(savePath); if (!dir.exists()) { testCaseLst = new String[1]; testCaseLst[0] = ""; } else { testCaseLst = dir.list(); } for (int i = 0; i < testCaseLst.length; i++) { if (testCaseLst[i].lastIndexOf(".tc") >= 0) { existName += testCaseLst[i].toUpperCase() + ","; } }%><html><head>............. axis2 发布webservice类 返回值类型为List 问题 一个关于数据库操作的问题 MyEclipse8.5在struts.xml里右键为什么没有New Action选项? 怎么样通过HTTP传输XML文档? 一个很奇怪的下载问题 问继承! BEAN的问题! JSP新手,给兄弟俺介绍本好书,好资料 js中使用Struts标签取中文值的问题!! 现在大家用jsp开发web页面传参都怎么传? 一个几天都没解决的问题 求解HttpClient实现网站自动登录
如果java读取会的话,jsp也就行了。
无非就是给个路径,然后用流进行读取。
http://edu.codepub.com/2009/0721/10530.php
pageEncoding="UTF-8"%>
<%@ page import="java.io.File"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%
String url = request.getRequestURL().toString();
String path = url.substring(0, url.lastIndexOf("/"));
String mainPath = path.substring(0, path.lastIndexOf("/"));
String msg = request.getParameter("msg");
if (msg == null) {
msg = "";
} String savePath = this.getServletContext().getRealPath("/")
+ "testcase";
System.out.println(savePath); //看看取到的哪个目录?
String[] testCaseLst = null;
String existName = "";
File dir = new File(savePath);
if (!dir.exists()) {
testCaseLst = new String[1];
testCaseLst[0] = "";
} else {
testCaseLst = dir.list();
}
for (int i = 0; i < testCaseLst.length; i++) {
if (testCaseLst[i].lastIndexOf(".tc") >= 0) {
existName += testCaseLst[i].toUpperCase() + ",";
}
}
%>
<html>
<head>.............