HttpServletRequest获取请求路径相关方法

自己对基础知识有点忘记了,写下来当作备忘。

http://127.0.0.1/demoPro/wx/auth/view?custa=001&authb=2

System.out.println(request.getContextPath());// /wkwm
System.out.println(request.getPathInfo());// null
System.out.println(request.getPathTranslated());// null
System.out.println(request.getQueryString()); // custNo=001&authType=2
System.out.println(request.getRequestURI());// /wkwm/wx/auth/view
System.out.println(request.getRequestURL().toString());// http://192.168.2.78/wkwm/wx/auth/view
System.out.println(request.getServletPath());// /wx/auth/view

你可能感兴趣的:(java编程)