System.out.print("路径:"+request.getContextPath()+"::"+ServletActionContext.getServletContext().getRealPath("/"));
结果:路径:/xxykt::D:\ProgramFiles\apache-tomcat-5.5.20\webapps\xxykt\
获取Web应用路径
本文介绍了一种在Java Web应用中获取当前应用上下文路径的方法,通过使用`System.out.print`结合`request.getContextPath()`和`getRealPath()`来输出完整的路径。
System.out.print("路径:"+request.getContextPath()+"::"+ServletActionContext.getServletContext().getRealPath("/"));
结果:路径:/xxykt::D:\ProgramFiles\apache-tomcat-5.5.20\webapps\xxykt\

被折叠的 条评论
为什么被折叠?