问题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. [转载]新手入门:Spring的一些学习方法及意见

    原文地址:新手入门:Spring的一些学习方法及意见作者:飞扬飞扬xyz Spring简介: 是一个开源框架,是为了解决企业应用程序开发复杂性而创建的.框架的主要优势之一就是其分层架构,分层架构允许您 ...

  2. 110. Balanced Binary Tree

    Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary ...

  3. Codeforces Round #377 (Div. 2) A B C D 水/贪心/贪心/二分

    A. Buy a Shovel time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...

  4. Letter Combinations of a Phone Number

    Given a digit string, return all possible letter combinations that the number could represent. A map ...

  5. 越狱Season 1-Episode 1: the pilot

    the pilot: 美国电视剧新剧开播都会有一个试播来测试观众对新剧的接受程度,以此来决定是否再继续播下去,也可以说是一个开端,第一集,试播 -Tattoo Artist: That's it. t ...

  6. DYNAMIC_DOWNCAST、STATIC_DOWNCAST、CRuntimeClass和IsKindOf

    DYNAMIC_DOWNCAST.STATIC_DOWNCAST.CRuntimeClass和IsKindOf   DYNAMIC_DOWNCAST(class, pointer ):如果pointe ...

  7. A better SHOW TABLE STATUS

    From command line we have the entire MySQL server on hands (if we have privileges too of course) but ...

  8. Linux体系结构(五): 文件系统

    上一节主要对Linux系统中的内核空间与用户空间做了简单的分析,在这一节里,将从内核空间和用户空间对Linux文件系统进行一定的剖析. 谈及文件系统,很多Linux用户都会有一个比较模糊和神秘的概念, ...

  9. ABBYY应用到的行业有哪些

    不同的行业组织和企业有不同的业务流程和规定,在OCR文字识别领域,ABBYY FineReader 12给各个行业都提供了有效解决方案,满足其特定需求的同时还帮助他们提高业务流程处理效率,降低成本,全 ...

  10. EntityFramework5.0CodeFirst全面学习

    Code First 约定 借助 CodeFirst,可通过使用 C# 或Visual Basic .NET 类来描述模型.模型的基本形状可通过约定来检测.约定是规则集,用于在使用 Code Firs ...