当前位置:网站首页>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 边栏推荐
猜你喜欢
随机推荐
【ACWing】406. 放置机器人
Wincc报表教程(SQL数据库的建立,wincc在数据库中保存和查询数据,调用Excel模板把数据保存到指定的位置和打印功能)
Excel文件读写(创建与解析)
DOM 基础操作
JSP request对象功能详解说明
ansible模块--copy模块
JSP out.print()和out.write()方法的不同之处
一篇永久摆脱Mysql时区错误问题,idea数据库可视化插件配置
【Leetcode】479. Largest Palindrome Product
当奈飞的NFT忘记了Web2的业务安全
多御安全浏览器android版更新至1.7,改进加密协议
在CentOS下安装MySQL
When Netflix's NFTs Forget Web2 Business Security
Short video SEO optimization tutorial Self-media SEO optimization skills and methods
在MySQL登录时出现Access denied for user ‘root‘@‘localhost‘ (using password YES) 拒绝访问问题解决
contentEditable属性
security cross-domain configuration
Flink Yarn Per Job - CliFrontend
C language Qixi is coming!It's time to show the romance of programmers!
CRS management and maintenance









