1. 程式人生 > >request獲取請求路徑的幾種方式

request獲取請求路徑的幾種方式

String nethod = request.getMethod();//獲取請求方式:
final String contextPath = request.getContextPath();//獲取專案名
String servletPath = request.getServletPath();//獲取網名 也就是/login
String requestURI = request.getRequestURI();//獲取訪問路徑: 專案名+servlet
StringBuffer requestURL = request.getRequestURL();// 獲取完整路徑: