`
lippeng
  • 浏览: 451720 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

Servlet路径问题

阅读更多

今天看公司框架的源码时,看到路径的问题,不是很清楚,到底哪个是哪个,就自己测了一下:

	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		System.out.println("getRequestURL:  " + request.getRequestURL());
		System.out.println("getRequestURI:  " + request.getRequestURI());
		System.out.println("getScheme:  " + request.getScheme());
		System.out.println("getServerName:  " + request.getServerName());
		System.out.println("getServerPort:  " + request.getServerPort());
		System.out.println("getContextPath:  " + request.getContextPath());
		System.out.println("getServletPath:  " + request.getServletPath());
	}

 然后访问,结果如下:

getRequestURL:  http://localhost:8080/TestServlet/Test
getRequestURI:  /TestServlet/Test
getScheme:  http
getServerName:  localhost
getServerPort:  8080
getContextPath:  /TestServlet
getServletPath:  /Test
 
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics