本文实例讲述了jsp获取url路径的方法。分享给大家供大家参考,具体如下:如果你请求的URL是 http://localhost:8080/demo/Index.jsprequest.getScheme() //输出:httprequest.g...
本文实例讲述了jsp获取url路径的方法。分享给大家供大家参考,具体如下:
如果你请求的URL是 http://localhost:8080/demo/Index.jsp
request.getScheme() //输出:http
request.getServerName() //输出: localhost
request.getServerPort() //输出: 8080
request.getContextPath() //输出: /demo
request.getRequestPath() //输出: /Index.jsp
request.gerRequestURI() //输出: /demo/Index.jsp
request.getRequestURL() //输出: http://localhost:8080/demo/Index.jsp
request.getRealPath("") //输出:D:\apache-tomcat-6.0.10\webapps\demo
上面几个我都验证过了,除了request.getRequestPath() 无法使用外(估计这个函数已经被废弃掉了吧),其它的显示都正确。
希望本文所述对大家JSP程序设计有所帮助。
沃梦达教程
本文标题为:jsp获取url路径的方法分析
猜你喜欢
- 基于Java Agent的premain方式实现方法耗时监控问题 2023-06-17
- SpringBoot使用thymeleaf实现一个前端表格方法详解 2023-06-06
- 深入了解Spring的事务传播机制 2023-06-02
- Spring Security权限想要细化到按钮实现示例 2023-03-07
- Java中的日期时间处理及格式化处理 2023-04-18
- Springboot整合minio实现文件服务的教程详解 2022-12-03
- JSP页面间传值问题实例简析 2023-08-03
- Java实现顺序表的操作详解 2023-05-19
- JSP 制作验证码的实例详解 2023-07-30
- ExecutorService Callable Future多线程返回结果原理解析 2023-06-01