`

HttpServletRequest中getContextPath,getServletPath,getRealPath,getRequestURI的区别

    博客分类:
  • java
阅读更多

  一眼看到这些获得获得路径的不同方法,有点迷糊,自己试验的一把,将结果贴出……

  请求过去的地址:http://localhost:8080/myweb/logistic/index.jsp

 

getContextPath   >>>>>>>>>   /myweb

getServletPath     >>>>>>>>>   /logistic/index.jsp

getRealPath("/")   >>>>>>>>>  F:\Tomcat5\webapps\myweb\

getRequestURI     >>>>>>>>>   /myweb/logistic/index.jsp

 

 

对比一下,就知道区别了

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics