request中getContextPath、getServletPath的区别

来源:互联网 发布:淘宝网棉麻连衣裙 编辑:程序博客网 时间:2024/06/15 03:48

  

访问:http://localhost:8080/app/testJsp.jsp


  <%=request.getContextPath()%> ·<!-- 返回站点的根路径。 -->      /app

  <%=request.getServletPath()%>   /testJsp.jsp
  <%=request.getRequestURI()%>  /app/testJsp.jsp
  <%=request.getRealPath("/")%>  <!-- 工程文件的实际物理路径 -->   E:\计算机视频\验证码\app\WebRoot\
 
  <%=request.getScheme() %><!-- 返回当前页面使用的协议,http 或是 https-->
  <%=request.getServerName()%>  <!-- 返回当前页面所在的服务器主机的名字; -->
  <%=request.getServerPort()%>    <!--  返回服务器接受此请求所用的端口号 -->
0 0
原创粉丝点击