【Java】【web】获取访问项目路径

2017-04-09  本文已影响146人  JerichoPH
String baseUrl = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath() + "/";
String basePath = request.getServletContext().getRealPath("/");
String currentClassPath = Thread.currentThread().getContextClassLoader().getResource("").getPath();
String currentFilePath = request.getServletPath();
// 或使用
String currentFilePath = request.getRequestURI();
String currentRequestUrl = request.getRequestURL();
上一篇下一篇

猜你喜欢

热点阅读