关于两个页面传递参数来显示图片

<%@ page contentType="text/html;charset=gb2312" %>
<%@ page import ="java.io.*" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>ex</title>
</head>
<body>
<%!
    class FileJSP implements FilenameFilter
     {
         String str=null;
         FileJSP(String s)
         {
           str="."+s;
         }
    public  boolean accept(File dir,String name)
         {
            return name.endsWith(str);
         }             
     }
%>
<P>下面列出了服务器上的jpg文件
  <%
    File dir=new File("d:/jsp/103/t");
    FileJSP file_jsp=new FileJSP("jpg");
    String file_name[]=dir.list(file_jsp); 

  File dir1=new File("d:/jsp/103/t");
    FileJSP file_jsp1=new FileJSP("gif");
    String file_name1[]=dir1.list(file_jsp1); 

 File dir2=new File("d:/jsp/103/t");
    FileJSP file_jsp2=new FileJSP("bmp");
    String file_name2[]=dir.list(file_jsp2);
 
 File dir3=new File("d:/jsp/103/t");
    FileJSP file_jsp3=new FileJSP("jpeg");
    String file_name3[]=dir.list(file_jsp3); 
 
   for(int i=0;i<file_name.length;i++)
           {
      out.print("<BR>"+"   "+file_name[i]+"<Input id='"+file_name[i]+"' type='button' value='查看'οnclick=/"window.open('showImage1.jsp?id="+ file_name[i]+"')/">");
           }
 
   for(int i=0;i<file_name1.length;i++)
           {
      out.print("<BR>"+"   "+file_name1[i]+"<Input id='"+file_name1[i]+"' type='button' value='查看'οnclick=/"window.open('showImage1.jsp?id="+ file_name1[i]+"')/">");
           }
 
   for(int i=0;i<file_name2.length;i++)
           {
      out.print("<BR>"+"   "+file_name2[i]+"<Input id='"+file_name2[i]+"' type='button' value='查看'οnclick=/"window.open('showImage1.jsp?id="+ file_name2[i]+"')/">");
           }
  
   for(int i=0;i<file_name3.length;i++)
           {
      out.print("<BR>"+"   "+file_name3[i]+"<Input id='"+file_name3[i]+"' type='button' value='查看'οnclick=/"window.open('showImage1.jsp?id="+ file_name3[i]+"')/">");
           }
 %>
</body>
</html> 

上面代码是显示图片 和按扭的页面

<%@ page contentType="text/html;charset=gb2312" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>ex</title>
</head>
<body>
<img src="d:/jsp/103/t/<%=request.getParameter("id")%>"  >
</body>
</html>

这个页面是显示图片的

这里我传递了id这个参数

οnclick=/"window.open('showImage1.jsp?id="+ file_name3[i]+"')/"

<%=request.getParameter("id")%>  这两句是主要代码


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值