JSP文件,獲取文件的相對路徑和絕對路徑
<% String url = request.getRequestURI(); //相對路徑 url = url.substring(url.lastIndexOf('/')); url = url.replace('/', '\\'); out.println("相對路徑"+url+"
"); String pa=application.getRealPath(""); //絕對路徑 out.println("絕對路徑"+pa+url+"
"); %>