我想在页面上输出每行四个图片,图片从固定文件夹中读取。以前用asp实现了,代码如下:
<%
Set fso=server.createobject("scripting.filesystemobject")
Set folder=fso.getfolder(server.mappath("album/small"))
c=1
For Each ii In folder.files
ii=Mid(ii,InstrRev(ii,"\")+1)
%>
<% if right(ii,9)<>"Thumbs.db" then %>
<td height="175" bgcolor="f2f5f7"> <table width="175" border="0" align="left" cellpadding="0" cellspacing="0">
<tr>
<td width="175" height="175"> <table width="120" height="90" border="0" align="center" cellpadding="0" cellspacing="0" class="bk">
<tr>
<td width="120" height="90" bgcolor="#FFFFFF"><a href="album/big/<%=Mid(ii,2)%>" target="_blank"><img src="album/small/<%=ii%>" width="120" height="90" border="0"></a></td>
</tr>
</table></td>
</tr>
</table></td>
<%end if%>
<% If c Mod 4=0 Then response.write "</tr><tr>"
c=c+1
Next %>
希望可以用jsp实现。请教高手,谢谢
<%
Set fso=server.createobject("scripting.filesystemobject")
Set folder=fso.getfolder(server.mappath("album/small"))
c=1
For Each ii In folder.files
ii=Mid(ii,InstrRev(ii,"\")+1)
%>
<% if right(ii,9)<>"Thumbs.db" then %>
<td height="175" bgcolor="f2f5f7"> <table width="175" border="0" align="left" cellpadding="0" cellspacing="0">
<tr>
<td width="175" height="175"> <table width="120" height="90" border="0" align="center" cellpadding="0" cellspacing="0" class="bk">
<tr>
<td width="120" height="90" bgcolor="#FFFFFF"><a href="album/big/<%=Mid(ii,2)%>" target="_blank"><img src="album/small/<%=ii%>" width="120" height="90" border="0"></a></td>
</tr>
</table></td>
</tr>
</table></td>
<%end if%>
<% If c Mod 4=0 Then response.write "</tr><tr>"
c=c+1
Next %>
希望可以用jsp实现。请教高手,谢谢
解决方案 »
- 我的myeclipse8.5中无法启动tomcat6.0,但是单独使用tomcat6.0能正常使用的。在myeclipse中启动报错如下。请高手指点……
- 用java将html转化为DOM树
- 菜鸟问问Sevlet调用的问题
- Vector 返回 null??? 请看这段代码
- XP更新后无法调用ACITVEX的方法
- 怎么取回搜索结果?
- 用什么软件作jsp的web服务器比较好(不是学习用的),如何配置
- Servlet生成的html页面显示中文问题,各位帮个忙
- 无法在Servlet中import 自定义的类,急!
- Java监听器怎么才能无限触发?
- 什么样的action必须要有相对应的ActionForm,也就是FormBean
- 使用validate后页面显示不全的问题
<table border="0" cellpadding="0" cellspacing="0" width="300">
<%
java.io.File small = new java.io.File(application.getRealPath("/album/small"));
java.io.File[] children = small.listFiles(new java.io.FilenameFilter() {// 取得 album/small 文件夹下的所有图像, 包括文件夹
public boolean accept(java.io.File dir, String name) {
name = name.toLowerCase();
if(name.endsWith(".jpg") || name.endsWith("png") || name.endsWith("gif"))
return true;
return false;
}
});
int index = 0;
out.print("<tr>");
for(int i = 0; children != null && i < children.length; i++) {
if(children[i].isDirectory())
continue;
if(index++ % 4 == 0)
out.print("</tr><tr>");
out.print("<td width=\"120\" height=\"90\" bgcolor=\"#FFFFFF\"><a href=\"album/big/" + children[i].getName() + "\" target=\"_blank\"><img src=\"album/small/" + children[i].getName() + "\" width=\"120\" height=\"90\" border=\"0\"></a></td>");
}
out.print("</tr>");
%>
</table>