用<html:file property="uploadFile" size="29" /> 上传的,但发现不能得到绝对地址~。!怎样能得到呢?还望高手帮忙啊!!谢谢啊!

解决方案 »

  1.   

    String path=request.getRealPath("");
    path 就取得了系统所在路径
    然后把你的上传文件夹的路径写上就OK 了
      

  2.   

    这招不行!getRealPath()在servlet中被禁止了!还有别的方法吗?
      

  3.   

    request.getAbsolutePath();这个试试看
      

  4.   

    楼上:没有这个方法呀?你说的request是HttpServletRequest request,这个嘛?
      

  5.   

    String abpath = getServlet().getServletContext().getRealPath("");
      

  6.   

    这个可以!!不过这个不合适吧?我查的资料:
    public Servlet getServlet(String name) throws ServletException;
    最初用来返回一个指定名称的Servlet,如果没找到就返回一个空值。如果这个Servlet能够返回,这就意味着它已经被初始化,而且已经可以接受service请求。
    这是一个危险的方法。当调用这个方法时,可能并不知道Servlet的状态,这就可能导致有关服务器状态的问题。而允许一个Servlet访问其他Servlet的这个方法也同样的危险。
    现在这个方法返回一个空值,为了保持和以前版本的兼容性,现在这个方法还没有被取消。在以后的API版本中,该方法将被取消。
      

  7.   

    等一下:有问题!我的flash放在\web\images\9.swf下,但getServlet().getServletContext().getRealPath("");只取出\web 这是怎么回事?
      

  8.   

    String abpath = getServlet().getServletContext().getRealPath("");
      

  9.   


    public static String storage_ringTone = "file"+File.separator+"storage"+File.separator+"ringTone"; public static String getRingToneStoragePath(HttpServletRequest request) {
        return request.getSession().getServletContext().getRealPath("") +
            File.separator + storage_ringTone;
      }
      

  10.   

    String abpath = getServlet().getServletContext().getRealPath("\web\images\9.swf");
      

  11.   

    jsp页面加入
    '&fullpath='+form1.file1.valueString clientPath = request.getParameter("fullpath");
    就可以的到客户端绝对地址了。