我的图像名称A(1),A(2)....... A(n)被放入根/文件夹中。 Tomcat告诉,如果我们在地址栏中提供图片URL,则无法显示图片,它有错误... 这是Show.jsp页面。
<%
String x = getServletContext().getContextPath().toString();
x=request.getServerName();
int y=request.getServerPort();
x=z+""+y+dir;
File f = new File(x);
if (f.isDirectory()) {
String[] fileList = f.list();
//out.println("Directory of " + x + "<br>");
for (int i = 0; i < fileList.length; i++) {
File f1 = new File( fileList[i]);
if (f1.isDirectory()) {
// to Show it is a directory
out.println(fileList[i] + " is a Directory<br>");
} else {
out.print("<br>");
out.print( fileList[i]); // file name list
%>
<img src="<%out.print(fileList[i]);%>" /> // image URL Dynamically
<br />
<%
}
}
} else {
out.println("<BR>");
}
%>