当前位置:网站首页>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 边栏推荐
猜你喜欢
随机推荐
security session concurrency management
重装腾讯云云监控后如果对应服务不存在可通过sc.exe命令添加服务
Short video seo search optimization main content
easy-excel 解决百万数据导入导出,性能很强
众筹DAO“枯萎”的缩影:曾拍下《沙丘》未出版手稿的Spice DAO解散
以交易为生是一种什么体验?
QML package management
mysql8安装make报错如何解决
【Leetcode】478. Generate Random Point in a Circle(配数学证明)
【ACWing】230. 排列计数
Excel表格数据导入MySQL数据库
面试必问的HashCode技术内幕
在不完全恢复、控制文件被创建或还原后,必须使用 RESETLOGS 打开数据库,解释 RESETLOGS.
[Three sons] C language implements simple three sons
在CentOS下安装MySQL
Deliver cloud-native microservices applications with Zadig
【MySQL篇】初识数据库
如何重装Win11?一键重装Win11方法
Zadig 面向开发者的自测联调子环境技术方案详解
QML包管理









