getContextPath:/test               //上下文,类似工程名 getServletPath:/test.jsp getRequestURI:/test/test.jsp getRequestURL:http://localhost:8080/test/test.jsp…
参考 https://blog.csdn.net/gavid0124/article/details/45390999/ request.getRequestURL() 返回全路径 request.getRequestURI() 返回除去host(域名或者ip)部分的路径 request.getContextPath() 返回工程名部分,如果工程映射为/,此处返回则为空 request.getServletPath() 返回除去host和工程名部分的路径 例如: request.getReque…
java获得tomcat项目的绝对地址 String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+request.getContextPath()+"/"; basePath : http://localhost:8080/test/ getRequestURI,getRequestURL的区别 test1.jsp…
getRequestURI,getRequestURL的区别 test1.jsp======================= <a href ="test.jsp?p=fuck">跳转到test2</a> test2.jsp======================= <%@ page language="java" import="java.util.*" pageEncoding="gb2312&q…
转自:http://www.cnblogs.com/JemBai/archive/2010/11/10/1873764.html test1.jsp======================= <a href ="test2.jsp?p=fuck">跳转到test2</a> test2.jsp======================= <%@ page language="java" import="java.util.…
比如说有这样的一个页面 test1.jsp======================= <a href ="test.jsp?name=wf">跳转到test2.jsp</a> test2.jsp======================= HttpServletRequest req = (HttpServletRequest) request; HttpServletResponse resp = (HttpServletResponse) respon…
test1.jsp======================= <a href ="test.jsp?p=fuck">跳转到test2</a> test2.jsp======================= <%@ page language="java" import="java.util.*" pageEncoding="gb2312"%><%String path = req…
假定你的web application 名称为news,你在浏览器中输入请求路径: http://localhost:8080/news/main/list.jsp 则执行下面向行代码后打印出如下结果: 1. System.out.println(request.getContextPath()); //可返回站点的根路径.也就是项目的名字 打印结果:/news    2.System.out.println(request.getServletPath()); 打印结果:/main/list.…
request.getRequestURL() 返回全路径 request.getRequestURI() 返回除去host(域名或者ip)部分的路径 request.getContextPath() 返回工程名部分,如果工程映射为/,此处返回则为空 request.getServletPath() 返回除去host和工程名部分的路径 例如: request.getRequestURL() http://localhost:8080/jqueryLearn/resources/request.j…
假定你的web application 项目名称为news,你在浏览器中输入请求路径: http://localhost:8080/news/main/list.jsp 则执行下面向行代码后打印出如下结果: 1. System.out.println(request.getContextPath()); //可返回站点的根路径.也就是项目的名字 打印结果:/news 2.System.out.println(request.getServletPath()); 打印结果:/main/list.j…