首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

在JSP里获取服务器的几个途径

2012-09-04 
在JSP里获取服务器的几个路径1、String contextPath request.getContextPath()String realPath reques

在JSP里获取服务器的几个路径
1、

String contextPath = request.getContextPath();
String realPath = request.getSession().getServletContext().getRealPath("/");
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+contextPath+"/";

2、
contextPath  = "/项目名称";  //获取的是项目的相对路径
realPath = F:\tomcat_home\webapps\项目名称\  //获取的是项目的绝对路径
basePath = http://localhost:8080/项目名称/   //获取的是服务的访问地址

热点排行
Bad Request.