request拿各种东西

例如 : http://localhost:8080/projectName/aaa/bbb?name=zhangsan
获取项目名(目录) /projectName
String uri = request.getContextPath();
获取目录下的全名称 /aaa/bbb
String url
= request.getServletPath();

获取当前页面所在服务器的全路径  d:\aaa\webapps\index.jsp
request.getRealPath("index.jsp")

在类中获取绝对路径
A.class.getResource("/").getPath

参考 : http://zjutsoft.iteye.com/blog/1084260

 

posted @ 2017-10-26 15:34  李勇888  阅读(130)  评论(0编辑  收藏  举报