假定你的web application 名称为news,你在浏览器中输入请求路径: http://localhost:8080/news/main/list.jsp 则执行下面向行代码后打印出如下结果: 1、 System.out.println(request.getContextPath()); 打印结果:/news
2、System.out.println(request.getServletPath()); 打印结果:/main/list.jsp
3、 System.out.println(request.getRequestURI()); 打印结果:/news/main/list.jsp
4、 System.out.println(request.getRealPath("/")); 打印结果: F:\Tomcat 6.0\webapps\news\test
相关文章
- PHPCMS v9点击量增加值加大的方法
- Python属性、方法和类管理系列之----__slots__属性
- el-table合计行前置在首行,自定义合计行方法
- ORM之自关联、add、set方法、聚合函数、F、Q查询和事务
- MySQL 大数据量快速插入方法和语句优化
- git报错解决方法error: remote origin already exists.-现在你可以这样做
- 【DevOps】OpenVPN 实现分流的几种方法和实战
- Hutool工具里,POST方法,body中传参的几种调用方法
- INNO 补丁制作技术, 打开 INNO 补丁制作方法的第一页
- 浅谈Java中的hashcode方法以及equals方法