我要在jsp中显示文件大小和最后修改时间该怎么写..jsp是用list装的文件名然后把他遍历到jsp中的.我刚才查了一下.好像是个File f=new File(路径);f.lastmodify();可是我jsp中怎么new 一个file啊.还有我的文件列表是从服务器取出来的路径该怎么写呢...
这是我从服务器取得文件列表的地址http://136.5.68.7:8080/creport/filelist?dir=20091111

解决方案 »

  1.   

    jsp页面最上面加<%@ page import="java.io.*" %>
    在body的合适位置用 <%
     File f = new File(路径);%>
      

  2.   

    我路径难道写http://136.5.68.7:8080/creport/filelist?dir=20091111  
      

  3.   


    获取路径:<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    %>
      

  4.   

    body的合适位置用 <% 
    File f = new File(new StringBuffer(request.getServletContext().getRealPath("/"))
    .append(java.io.File.separator).append("creport").append(java.io.File.separator)
    .append("filelist?dir=20091111")); %> http://136.5.68.7:8080/creport/filelist?dir=20091111