问题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. Educational Codeforces Round 15 A dp

    A. Maximum Increase time limit per test 1 second memory limit per test 256 megabytes input standard ...

  2. JS初学之-循环生成坐标

    <!doctype html><html><head><meta charset="utf-8"><title>无标题文 ...

  3. leetcode 95 Unique Binary Search Trees II ----- java

    Given an integer n, generate all structurally unique BST's (binary search trees) that store values 1 ...

  4. Linux 下WordPress FTP帐号解决办法

    自己用Ubuntu搭建WordPress后在更换主题时提示需要输入FTP帐号和密码,解决办法主要是把WordPress主目录的权限所有者弄为Apache: 找到apache服务所使用的用户名和用户组 ...

  5. Unity Shader _Time

    _Time是个4维向量,跟Unity3D中的deltaTime(这是个一维的,数值)不同. float4 _Time : Time (t/20, t, t*2, t*3), use to animat ...

  6. javascript往textarea追加内容

    <html> <body> <textarea id="content"></textarea> <script> va ...

  7. Java 性能优化

    http://eclipsesource.com/blogs/2013/01/21/10-tips-for-using-the-eclipse-memory-analyzer/ http://docs ...

  8. jquery mouseout事件错误(bug)

    移到子元素上时(例如,处在div中的图像),触发移出事件 (mouseout事件的一个常见错误). 解决办法是使用hover事件 在使用hover事件前,我抓耳挠腮的以为是margin或padding ...

  9. Is it possible to configure PostgreSQL to automatically close idle connections?

    1.use pgbouncer As new connections/transactions/statements arrive, the pool will increase in size up ...

  10. Jquery easyui的validatebox控件和正则表达式

    http://blog.csdn.net/dandanzmc/article/details/36421465 仔细观察jquery.validatebox.js文件,会发现它的验证其实还是采用的正则 ...