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

1. request.getContextPath();在普通的java代码中用,当然也可以在jsp中用:<% String contextPath = request.getContextPath(); %>

2. ${pageContext.request.contextPath} jsp中el表达式,在jsp页面中用;

(2) 不同的部署war包名(或者说应用路径名不一样),那么上下文路径不一样:

当在webapps中部署war包为:ROOT.war时,这时上下文路径为默认的:空字符串      

当在webapps中部署war包为:platform.war时,这时上下文路径为:/platform  

上下文路径request.getContextPath();与${pageContext.request.contextPath}的更多相关文章

  1. String path = request.getContextPath(); String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";作用!!!!!

    <%String path = request.getContextPath();String basePath = request.getScheme()+"://"+re ...

  2. <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %>

    <%String path = request.getContextPath();String basePath = request.getScheme()+"://"+re ...

  3. jsp中的<% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %>

    <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+ ...

  4. jsp页面String path = request.getContextPath(); String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";作用!!!!!

    转自:https://blog.csdn.net/kiwangruikyo/article/details/81130311 <%String path = request.getContext ...

  5. 关于String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

    关于 String path = request.getContextPath(); String basePath = request.getScheme()+"://"+req ...

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

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

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

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

  8. request.getContextPath获取绝对路径

    request.getContextPath获取绝对路径 博客分类: 经验+注意 其他 request.getContextPath 项目需求:所有jsp页必须通过Action转发,不能直接在地址栏链 ...

  9. jsp里面不能使用${pageContext.request.contextPath}解决方案

    1.在jsp中使用${pageContext.request.contextPath}获取相对路径,可是最后路径变为:http://localhost:8080/oneself/$%7BpageCon ...

随机推荐

  1. POJ 2287 田忌赛马 贪心算法

    田忌赛马,大致题意是田忌和国王赛马,赢一局得200元,输一局输掉200元,平局则财产不动. 先输入一个整数N,接下来一行是田忌的N匹马,下一行是国王的N匹马.当N为0时结束. 此题为贪心算法解答,有两 ...

  2. JS判断备忘

    快速引入jquery并显示重点内容 (function(d,j,s,t){t=d.body.appendChild(d.createElement("script"));t.onl ...

  3. 20172305 2018-2019-1 《Java软件结构与数据结构》第一周学习总结

    20172305 2018-2019-1 <Java软件结构与数据结构>第一周学习总结 教材学习内容总结 本周内容主要为书第一章和第二章的内容: 第一章 软件质量: 正确性(软件达到特定需 ...

  4. Hadoop之block研究

        本文翻译原链接:https://hadoopabcd.wordpress.com/2015/03/17/hdfs-file-blocks-distribution-in-datanodes/ ...

  5. Java中终止正在运行线程

    问题:java 中如何让一个正在运行的线程终止掉? Demo_1: class TT implements Runnable { private boolean flag = true; @Overr ...

  6. 2-c语言作业1

    #include<stdio.h> #include<math.h> int main(void) { int money,year; double rate,sun; pri ...

  7. HDU 2068 Choose the best route

    http://acm.hdu.edu.cn/showproblem.php?pid=2680 Problem Description One day , Kiki wants to visit one ...

  8. cacti添加多个tomcat监控(多端口)

    1.修改tomcat的模版 Data Input Methods->Tomcat Status 把原本固定的端口,用户名和密码手动修改成变量(绿线标出的),之后save保存之后,再在Input ...

  9. MongoDB、ElasticSearch、Redis、HBase这四种热门数据库的优缺点及应用场景

    MongoDB MongoDB是当今最火爆的NoSQL数据库.MongoDB最早在09年发布,算得上是早期大数据时代的数据库代表作了.随着MongoDB的火爆,研发MongoDB的团队还专门成立了Mo ...

  10. matlab读图函数

    最基本的读图函数:imread imread函数的语法并不难,I=imread('D:\fyc-00_1-005.png');其中括号内写图片所在的完整路径(注意路径要用单引号括起来).I代表这个图片 ...