requestscope.contextpath和<%=request.getContextPath()%>有何区别?(待解答)
问题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()%>有何区别?(待解答)的更多相关文章
- pageContext.request.contextPath 和 request.getContextPath()
作用是取出部署的应用程序名,这样不管如何部署,所用路径都是正确的. El表达式的写法:${pageContext.request.contextPath} jsp的写法:<%=request.g ...
- JSP之项目路径问题(${pageContext.request.contextPath},<%=request.getContextPath()%>以及绝对路径获取)
本随笔这是作为一个记录使用,以备后查.项目完成之后本地部署OK,本地Linux部署OK,都可以正常的访问,可是当我把它部署到服务器上面的时候,首页可以正常访问,可是当发出请求的时候却报错误了,说找不到 ...
- request.getcontextPath() 详解
request.getcontextPath() 详解 文章分类:Java编程 <%=request.getContextPath()%>是为了解决相对路径的问题,可返回站点的根路径. 但 ...
- request.getcontextPath() 详解(转)
本文转自:http://blog.csdn.net/pengxuan/article/details/6604578 <%=request.getContextPath()%>是为了解决相 ...
- request.getcontextPath() 详解 和 <link标签>
classpath:只会到你的class路径中查找找文件; classpath*:不仅包含class路径,还包括jar文件中(class路径)进行查找. 绝对路径: D:\磊弟资料\最代码\智父子考试 ...
- 上下文路径request.getContextPath();与${pageContext.request.contextPath}
(1) request.getContextPath();与${pageContext.request.contextPath}都是获取上下文路径: 1. request.getContextPath ...
- WEBROOT根目录 <%=request.getContextPath()%>
WEBROOT根目录 <%=request.getContextPath()%> == ${pageContext.request.contextPath}
- jsp中【<%=request.getContextPath()%>】项目路径
1 2 "request.getContextPath()的值是 "<%=request.getContextPath()%><br/> &q ...
- (转)关于request.getServletPath(),request.getContextPath()的总结
文章完全转载自 : https://blog.csdn.net/qq_27770257/article/details/79438987 最近对于request中的几种“路径”有点混淆,查找网上资源都 ...
随机推荐
- DB2 函数大全
DB2函数大全 函数名 函数解释 函数举例 AVG() 返回一组数值的平均值. SELECTAVG(SALARY)FROMBSEMPMS; CORR(),CORRELATION() 返回一对数值的关系 ...
- Mac中Fn键技巧
此文适用:Mac自带苹果键盘或外接有Fn键的普通键盘 上一页=Fn+⬅️ 下一页=Fn+➡️ 向上卷动=Fn+⬆️ 向下卷动=Fn+⬇️
- dll清理
結束了閉關,又得與人類交流了,只好裝QQ 印象中企鵝手腳一向是BAT中最乾淨的-結果還是裝了不少樂色,一併挖出來除之 C:\program files\common files\tencent\q ...
- ZOJ 1202 Divide and Count
原题链接 题目大意:某人手上有一大批钻石,他同时有一些盒子恰好放下这些钻石,每个盒子可以放一个或多个,问一共有几种方法. 解法:这其实是一道排列与组合计算题,主要是写出组合算法的代码,把计算公式转为程 ...
- codeforces 192a
link: http://codeforces.com/contest/330/problem/A brute force. /* ID: zypz4571 LANG: C++ TASK: 191a. ...
- JavaWeb学习记录(一)——response响应头之缓存设置与下载功能的实现
一.HTTP中常用响应头 Location: http://www.it315.org/index.jsp Server:apache tomcat Content-Encoding: gzip Co ...
- hihoCoder #1033 : 交错和 (数位Dp)
题目大意: 给定一个数 x,设它十进制展从高位到低位上的数位依次是 a0, a1, ..., an - 1,定义交错和函数: f(x) = a0 - a1 + a2 - ... + ( - 1)n - ...
- mave之:java的web项目必须要的三个jar的pom形式
jsp-api javax.servlet-api jstl <!-- jsp --> <dependency> <groupId>javax.servlet< ...
- Java设计模式之责任链设计模式
职责链模式(Chain of Responsibility):使多个对象都有机会处理请求,从而避免请求的发送者和接收者之间的耦合关系,将所有处理对象连成一条链,并沿着这条链传递请求,直到有一个对象处理 ...
- numpy下的flatten()函数用法
flatten是numpy.ndarray.flatten的一个函数,其官方文档是这样描述的: ndarray.flatten(order='C') Return a copy of the arra ...