当前位置:网站首页>JSP how to obtain the path information in the request object?
JSP how to obtain the path information in the request object?
2022-08-02 00:18:00 【qq_25073223】
From:
http://www.java265.com/JavaCourse/202112/2060.html
The following author describes the method of obtaining the absolute path, virtual path and other information in the request object using the example method, as shown below:
Implementation ideas:Example 1: Project name "maomao"getContextPath(): Get the project nameResult: /maomaogetServletPath() Get the full name of the directory where the current page is located/maomao/jsp/test.jspgetRequestURL() gets the IE address bar addressResult: http://localhost:8080/maomao/testgetServletPath() gets the relative addressResult: /maomao/testExample 2: jsp request address: http://127.0.0.1:8080/projectName/test/testSearch.jsp, various paths are obtained as follows:request.getServletPath():/test/testSearch.jsprequest.getContextPath():/projectNamerequest.getRequestURL(): http://127.0.0.1:8080/projectName/test/testSearch.jsprequest.getRemoteAddr():127.0.0.1request.getServletContext():[email protected].getServerPort():8080request.getScheme():httprequest.getServerName():127.0.0.1request.getProtocol(): HTTP/1.1request.getPathInfo():nullrequest.getQueryString():null
边栏推荐
猜你喜欢
随机推荐
Excel导入和导出
工业信息物理系统攻击检测增强模型
基于相关性变量筛选偏最小二乘回归的多维相关时间序列建模方法
微软电脑管家V2.1公测版正式发布
如何发现新的潜力项目?工具推荐
How to get the best power efficiency in Windows 11?
easy-excel 解决百万数据导入导出,性能很强
DOM 基础操作
【Leetcode】470. Implement Rand10() Using Rand7()
具有通信时延的多自主体系统时变参考输入的平均一致性跟踪
LeetCode_279_完全平方数
【ACWing】406. 放置机器人
Double queue implementation stack?Dual stack implementation queue?
What is it like to trade for a living?
如何优雅的消除系统重复代码
双队列实现栈?双栈实现队列?
不就是个TCC分布式事务,有那么难吗?
QML package management
Simpson's paradox
Async/await principle and execution sequence analysis









