String path = request.getRealPath("/")+photos.getName();//文件夹
File dir = new File(path);
File[] files = dir.listFiles();
然后获得每个图片的绝对路径 ……
可以吗?客户端会不会有显示?

解决方案 »

  1.   

    是不是在脚本里 可以用绝对路径遍历,然后到了<img/>里就要用相对路径?
      

  2.   

    Java板块不景气啊,怎么没人来?
      

  3.   


    可以的 但是你需要权限【用户名/密码】我给你的 代码 是遍历FTP服务器上的文件
    import java.io.IOException;
    import java.io.PrintWriter;
    import org.apache.commons.net.PrintCommandListener;
    import org.apache.commons.net.ftp.FTPClient;
    import org.apache.commons.net.ftp.FTPFile;
    import org.apache.commons.net.ftp.FTPReply;
    public class FTPListAllFiles {  
        public FTPClient ftp;
        public FTPListAllFiles(boolean isPrintCommmand){   
            ftp = new FTPClient();    
            if(isPrintCommmand){   
                ftp.addProtocolCommandListener(new PrintCommandListener(new PrintWriter(System.out)));   
            }   
        }    
        public boolean login(String host,int port,String username,String password) throws IOException{   
            this.ftp.connect(host,port);   
            if(FTPReply.isPositiveCompletion(this.ftp.getReplyCode())){   
                if(this.ftp.login(username, password)){   
                    this.ftp.setControlEncoding("GBK");   
                    return true;   
                }   
            }   
            if(this.ftp.isConnected()){   
                this.ftp.disconnect();   
            }   
            return false;   
        } 
        public void disConnection() throws IOException{   
            if(this.ftp.isConnected()){   
                this.ftp.disconnect();   
            }   
        }   
        public void List(String pathName) throws IOException{   
           if(pathName.startsWith("/")&&pathName.endsWith("/")){   
               String directory = pathName;   
               this.ftp.changeWorkingDirectory(directory);   
               FTPFile[] files = this.ftp.listFiles();
               for(int i=0;i<files.length;i++){
                  System.out.println("得到文件:"+files[i].getName());
                  if(files[i].isFile()){ 
               }else if(files[i].isDirectory()){   
                   List(directory+files[i].getName()+"/");   
               }
               }
            }   
        }
       public static void main(String[] args) throws IOException {   
            FTPListAllFiles f = new FTPListAllFiles(true);   
            if(f.login("192.168.1.100", 21, "zhuchao", "zhuchao")){   
             f.List("/app/"); //地址,端口号,用户名,密码  
            }   
            f.disConnection(); 
        }   
    } 我用SERVERU测试过的,希望对你有帮助。
      

  4.   

    可以遍历。你去apache网站上下载某个中间件的时候,如down一个struts。
    网站会给你以文件系统的形式把struts的各个版本详情给你列出来,而且可以导航
      

  5.   

    没有问题~
    jsp最后会生成java代码
    然后由servlet写出,所以服务端执行的代码客户端是看不到的。
    客户端看到的是jsp生成的对象所打印出来的结果。
      

  6.   


    显示当然可以显示啊,只是客户端不能操作,因为JSP页面只能操作web-info目录下的权限,其他的都不可以。