下面的JSP代码是什么作用的?

来源:百度知道 编辑:UC知道 时间:2024/05/23 12:41:41
1,request对象中有getContextPath方吗?干什么用的?
2,下面代码具体实现什么功能
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

request.getScheme()得到协议,如http

request.getServerName()得到服务器名或ip地址或域名,如www.sohu.com

request.getServerPort()得到端口好,如8080

request.getContextPath()得到你的web模块,如www.sohu.com/abc中的abc

目的是得到你浏览器的完整路径