<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.io.File"%>
<%@ page import="java.io.FilenameFilter"%>
<html>
<head>
<title>
文件显示</title>
</head>
<body>
<h1 align="center">
<center>
<h1>请选择要下载的文件</h1>
<table border=1 align=center width=80%>
<%
File f1=new File("c:/tomcat6.0/webapps/JSP");
String s[]=f1.list();
for(int i=0;i<s.length;i++){
String ss=s[i];
out.println("<tr><form method=post action='smp49.jsp'><td bgcolor=yellow><input type=hidden
name=name1 value="+ss+">"+ss+"</td><td><input type=submit value=下载></td></form></tr>"); }
%>
</table>
</center>
</h1>
</body></html>总是提示红色部分错误,是哪里字符串联接错了吗?
<%@ page import="java.io.File"%>
<%@ page import="java.io.FilenameFilter"%>
<html>
<head>
<title>
文件显示</title>
</head>
<body>
<h1 align="center">
<center>
<h1>请选择要下载的文件</h1>
<table border=1 align=center width=80%>
<%
File f1=new File("c:/tomcat6.0/webapps/JSP");
String s[]=f1.list();
for(int i=0;i<s.length;i++){
String ss=s[i];
out.println("<tr><form method=post action='smp49.jsp'><td bgcolor=yellow><input type=hidden
name=name1 value="+ss+">"+ss+"</td><td><input type=submit value=下载></td></form></tr>"); }
%>
</table>
</center>
</h1>
</body></html>总是提示红色部分错误,是哪里字符串联接错了吗?
改成out.println(" <tr> <form method=post action='smp49.jsp'> <td bgcolor=yellow> <input type=hidden "+
"name=name1 value="+ss+">"+ss+" </td> <td> <input type=submit value=下载> </td> </form> </tr>");
首先你如果把红色部分分两行的话
你就应该这样
out.println(" <tr> <form method=post action='smp49.jsp'> <td bgcolor=yellow> <input type=hidden "+
"name=name1 value="+ss+">"+ss+" </td> <td> <input type=submit value=下载> </td> </form> </tr>"); 如果你是在一行的话那就不是这里的错...我怀疑你报nullpoint错误吧!
String s[]=f1.list();
这里的s你打印出来看是不是null
System.out.println(s);
name=name1 value="+ss+">"+ss+" </td> <td> <input type=submit value=下载> </td> </form> </tr>");接分