问题1:requestscope.contextpath和<%=request.getContextPath()%>有何区别?

问题2:${requestscope.contextpath}和${pageContext.request.contextPath}有何区别?

需要访问一个AuthorityServlet服务器,该Servlet服务器在web.xml中的配置为:

<servlet>
<servlet-name>AuthorityServlet</servlet-name>
<servlet-class>com.tt.javaweb.servlet.AuthorityServlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>AuthorityServlet</servlet-name>
<url-pattern>/authorityServlet</url-pattern>
</servlet-mapping>

很明显,url-pattern里的/代表当前WEB应用的名称:20161025,即需要以/20161025/authorityServlet访问AuthorityServlet服务器。

获取当前当前WEB应用的名称:request.getContextPath()=/20161025,(其中/代表当前站点的根目录:http://localhost:8080)

访问方式:<%= request.getContextPath() %>/authorityServlet等价于/20161025/authorityServlet,通过此方式可以访问AuthorityServlet服务器。

现在问题在于:${requestScope.contextPath }/authorityServlet为什么无法访问AuthorityServlet服务器?

难道${requestScope.contextPath }和<%= request.getContextPath() %>不相等吗?

而${requestScope.contextPath }authorityServlet却可以访问到AuthorityServlet服务器?

requestscope.contextpath和<%=request.getContextPath()%>有何区别?(待解答)的更多相关文章

  1. pageContext.request.contextPath 和 request.getContextPath()

    作用是取出部署的应用程序名,这样不管如何部署,所用路径都是正确的. El表达式的写法:${pageContext.request.contextPath} jsp的写法:<%=request.g ...

  2. JSP之项目路径问题(${pageContext.request.contextPath},<%=request.getContextPath()%>以及绝对路径获取)

    本随笔这是作为一个记录使用,以备后查.项目完成之后本地部署OK,本地Linux部署OK,都可以正常的访问,可是当我把它部署到服务器上面的时候,首页可以正常访问,可是当发出请求的时候却报错误了,说找不到 ...

  3. request.getcontextPath() 详解

    request.getcontextPath() 详解 文章分类:Java编程 <%=request.getContextPath()%>是为了解决相对路径的问题,可返回站点的根路径. 但 ...

  4. request.getcontextPath() 详解(转)

    本文转自:http://blog.csdn.net/pengxuan/article/details/6604578 <%=request.getContextPath()%>是为了解决相 ...

  5. request.getcontextPath() 详解 和 <link标签>

    classpath:只会到你的class路径中查找找文件; classpath*:不仅包含class路径,还包括jar文件中(class路径)进行查找. 绝对路径: D:\磊弟资料\最代码\智父子考试 ...

  6. 上下文路径request.getContextPath();与${pageContext.request.contextPath}

    (1) request.getContextPath();与${pageContext.request.contextPath}都是获取上下文路径: 1. request.getContextPath ...

  7. WEBROOT根目录 <%=request.getContextPath()%>

    WEBROOT根目录 <%=request.getContextPath()%> == ${pageContext.request.contextPath}

  8. jsp中【<%=request.getContextPath()%>】项目路径

    1 2 "request.getContextPath()的值是        "<%=request.getContextPath()%><br/> &q ...

  9. (转)关于request.getServletPath(),request.getContextPath()的总结

    文章完全转载自 : https://blog.csdn.net/qq_27770257/article/details/79438987 最近对于request中的几种“路径”有点混淆,查找网上资源都 ...

随机推荐

  1. hdu 5902 Seam Carving

    水题,直接上代码了 #include<cstdio> #include<cstring> #include<iostream> #include<cmath& ...

  2. Sqlserver 远程连接的 TCP/IP 和 Named Pipes的区别

    TCP/IP:  TCP/IP是 Internet 上广泛使用的通用协议.它与互连网络中硬件结构和操作系统各异的计算机进行通信.TCP/IP包括路由网络流量的标准,并能够提供高级安全功能.它是目前在商 ...

  3. emulator: ERROR: Unable to load VM from snapshot. The snapshot has been saved for a different hardware configuration.

    emulator: ERROR: Unable to load VM from snapshot. The snapshot has been saved for a different hardwa ...

  4. UI学习笔记---第二天

    程序的执行流程 一.自定义视图 自定义UILebal-UITextField视图 ⾃定义视图:系统标准UI之外,⾃己组合而出的新的视图. 实际开发中,我们还需⾃定义视图.积累⾃己的代码库.⽅便开发. ...

  5. WebApp远程调试工具

    针对存在内嵌在客户端的webview项目中,在开发过程中我们希望能像PC上一下直接进行调试,提高我们平时的开发效率,这时候我们可以使用webApp远程调试工具-weinre. 安装: 本工具需要nod ...

  6. hive权限管理之实践

    一.实践心得 主要参考这个连接,里面说得也挺详细的.http://www.aboutyun.com/thread-12549-1-1.html 总结如下: 1.若赋予用户某个表的权限,查用户在该表所属 ...

  7. stl中双向队列用法

    双向队列的操作如下: d[i]:返回d中下标为I的元素的引用. d.front():返回的一个元素的引用. d.back():返回最后一个元素的引用. d.pop_back():删除尾部的元素.不返回 ...

  8. hihoCoder #1040 (判断是否为矩形)

    题目大意:给四条线段,问能否构成一个矩形? 题目分析:先判断能否构成四边形,然后选一条边,看另外三条边中是否为一条与他平行,两条垂直. 代码如下: # include<iostream> ...

  9. JavaScript判断IE各版本最完美解决方案

    https://github.com/nioteam/jquery-plugins/issues/12 jQuery在1.9版本之前,提供了一个浏览器对象检测的属性$.browser,使用率极高.但是 ...

  10. 《Linux与Qt程序设计》知识框架

    本文主要是通过一本书来大致了解Qt开发的框架,不对具体内容做详细分析. 1.首先弄清楚概念:定义->以自己的话理解是什么-> 实现的是什么功能->用在哪些地方 2.前面认识到的知识点 ...