request.getcontextpath request.getrealpath request.getServletPath() request.getRequestURI()
2018-01-10 14:30
113 查看
原来的地址忘了,谁发现提醒一下我,我好加上
1 区别
假定你的web application 名称为news,你在浏览器中输入请求路径:
http://localhost:8080/news/main/list.jsp
1.1 System.out.println(request.getContextPath());
打印结果:/news
1.2 System.out.println(request.getServletPath());
打印结果:/main/list.jsp
1.3 System.out.println(request.getRequestURI());
打印结果:/news/main/list.jsp
1.4 System.out.println(request.getRealPath("/"));
打印结果:F:\Tomcat 6.0\webapps\news\
1 区别
假定你的web application 名称为news,你在浏览器中输入请求路径:
http://localhost:8080/news/main/list.jsp
1.1 System.out.println(request.getContextPath());
打印结果:/news
1.2 System.out.println(request.getServletPath());
打印结果:/main/list.jsp
1.3 System.out.println(request.getRequestURI());
打印结果:/news/main/list.jsp
1.4 System.out.println(request.getRealPath("/"));
打印结果:F:\Tomcat 6.0\webapps\news\
相关文章推荐
- STL 中优先队列priority_queue
- Qt在 Mac系统发布程序(widgets和quick2)生成dmg安装文件。
- 数据分析展现工具SDC UE
- layui滚动加载
- Re:Android 设计模式-Builder
- 简单谈谈vue的属性。。。
- Java集合类(二十二)JUC中的集合--ConcurrentLinkedQueue
- [DP] ARC074 E - RGB Sequence
- The maximum number of processes for the user account running is currently , which can cause performance issues. We recommend increasing this to at least 4096.
- STL中的队列queue
- Java集合类(二十一)JUC中的集合--LinkedBlockingDeque
- 利用SoapUI 测试web service的一些问题总结
- 使用css3变量修改elementUI原始样式
- Java集合类(二十)JUC中的集合--LinkedBlockingQueue
- 百度编辑器Ueditor1.4.3的使用
- UIKit框架-高级视图-UIDatePicker-时间选择器
- stm32f429移植uGUI
- 最详细的Vuex教程
- Java StringBuffer与StringBuider
- Vue 中使用vue2-highcharts实现实时曲线数据展示示例