只要能得到前面的就行了 比如 http://localhost:8080/gir 我要得到前面的 加上 工程名字 能动态得到就好了 拼字符串的方法也行

解决方案 »

  1.   

    你是想在javaBean當中獲得路徑吧。其實很簡單啊,建一個帶request參數的函數,JSP頁面上調用這個函數不就可以  使用request了嗎
      

  2.   

    不是哦 就是不能用到REQUEST这个对象 我的问题是使用QUARTZ在WEB启动的时候就 出发一个JOB执行 这个里面正好要用到 WEB的路径 我想了好久 总是没办法得到
      

  3.   

    String root=getServletContext().getRealPath("/");
      

  4.   

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

  5.   

    String root=getServletContext().getRealPath("/");
      

  6.   

    String root=getServletContext().getRealPath("/");得到的是物理地址
      

  7.   

    上面方法好像都是要用的web环境的,而不是在一个普通javaBean中吧~