问题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. C# 托管资源和非托管资源

    托管资源指的是.NET可以自动进行回收的资源,主要是指托管堆上分配的内存资源.托管资源的回收工作是不需要人工干预的,有.NET运行库在合适调用垃圾回收器进行回收. 非托管资源指的是.NET不知道如何回 ...

  2. HDU 4311 前缀和

    Description It has been ten years since TJU-ACM established. And in this year all the retired TJU-AC ...

  3. HDU 4597 记忆化搜索

    ² 博弈取牌—记忆化搜索 题目描述: 有两副带有数字的牌,(数字>0)两人轮流取,取中了某张牌,自己的分数就加上牌上的数字,但只能从两端取,每人都会用最优的策略使得自己的分数最高.问A先取,他能 ...

  4. UVa1589 象棋

    就是声明两个数组,一个模拟棋局,另一个模拟黑将不能走的位置.不过写得有点长了... #include<iostream> #include<string> using name ...

  5. Maven项目中找不到maven dependencies library

    一般是,workspace中的.classpath文件中有内容丢失造成 在 <classpathentry kind="con" path="org.eclipse ...

  6. 1-4-1 Windows应用程序组成及编程步骤

    主要内容:介绍Windows应用程序的组成以及编程步骤 1.应用程序的组成 <1>一个完整的应用程序通常由五种类型的文件组成 1.源程序文件 2.头文件 3.模块定义文件 4.资源描述文件 ...

  7. window7资源管理器一直重启(百度知道找到可用)

    今天我的机器也出现这种问题:我的解决方式是,在开机时选择系统修复选项中的进入命令行方式(尝试过用安全模式,文件被占用,现象一样),然后cd C:\Users\Administrator\AppData ...

  8. sessionStorage和localStorage中 存储

    转:http://my.oschina.net/crazymus/blog/371757 sessionStorage只在页面打开是起作用, localStorage关闭页面后仍然起作用. 有时候,我 ...

  9. A Gentle Introduction to the Gradient Boosting Algorithm for Machine Learning

    A Gentle Introduction to the Gradient Boosting Algorithm for Machine Learning by Jason Brownlee on S ...

  10. caffe: train error: Serializing 25 layers--- Check failed: proto.SerializeToOstream(&output)

    I0221 21:47:41.826748  6797 solver.cpp:259]     Train net output #0: loss = 0.00413362 (* 1 = 0.0041 ...