当前位置:网站首页>JSP 如何获取request对象中的路径信息呢?
JSP 如何获取request对象中的路径信息呢?
2022-08-02 00:01:00 【qq_25073223】
转自:
http://www.java265.com/JavaCourse/202112/2060.html
下文笔者讲述使用示例的方式获取request对象中的绝对路径,虚拟路径及其它信息的方法分享,如下所示:
实现思路:
例1:工程名“maomao”
getContextPath():获取工程名
结果:/maomao
getServletPath() 得到当前页面所在目录下全名称
/maomao/jsp/test.jsp
getRequestURL() 得到IE地址栏地址
结果:http://localhost:8080/maomao/test
getServletPath() 得到相对地址
结果:/maomao/test
例2:jsp请求地址:http://127.0.0.1:8080/projectName/test/testSearch.jsp,各种路径获取如下:
request.getServletPath():/test/testSearch.jsp
request.getContextPath():/projectName
request.getRequestURL():http://127.0.0.1:8080/projectName/test/testSearch.jsp
request.getRemoteAddr():127.0.0.1
request.getServletContext():[email protected]
request.getServerPort():8080
request.getScheme():http
request.getServerName():127.0.0.1
request.getProtocol():HTTP/1.1
request.getPathInfo():null
request.getQueryString():null 边栏推荐
猜你喜欢
随机推荐
22. The support vector machine (SVM), gaussian kernel function
How to get the best power efficiency in Windows 11?
【MySQL系列】MySQL索引事务
Thinkphp 5.0.24变量覆盖漏洞导致RCE分析
不就是个TCC分布式事务,有那么难吗?
Bean的生命周期
微软电脑管家V2.1公测版正式发布
短视频SEO优化教程 自媒体SEO优化技巧方法
【Leetcode】475. Heaters
632. 最小区间
TCL:在Quartus中使用tcl脚本语言进行管脚约束
回顾历史5次经济衰退时期:这一次可能会有何不同?
JSP Taglib指令具有什么功能呢?
Excel文件读写(创建与解析)
GIF making - very simple one-click animation tool
asyncawait和promise的区别
【Leetcode】479. Largest Palindrome Product
Win10安装DBeaver连接MySQL8、导入和导出数据库详细教程
Short video SEO search operation customer acquisition system function introduction
async和await用法介绍









