获取当前应用的相对路径

    public String getApplicationContextPath(CommonUploadAware myUpload){
    	HttpServletRequest request = myUpload.getM_request();
//    	System.out.println("getRealContextPath" + EAPConfigHelper.getRealContextPath(request.getSession().getServletContext()));
//    	System.out.println("getRealApplicationPath" + EAPConfigHelper.getRealApplicationPath(request.getSession()));
//    	System.out.println("getRealPath1" + request.getSession().getServletContext().getRealPath("/")); 
		URL url = null ; String weblogic_path = null;
		try {
			url = request.getSession().getServletContext().getResource("/");
			weblogic_path = url.getPath();
			System.out.println("weblogic_path" + weblogic_path); 
		} catch (MalformedURLException e) {
			e.printStackTrace();
		}
        return weblogic_path;
    }

 

你可能感兴趣的:(Java)