比如说有这样的一个页面
test1.jsp=======================
<a href ="test.jsp?name=wf">跳转到test2.jsp</a>
test2.jsp=======================
- HttpServletRequest req = (HttpServletRequest) request;
- HttpServletResponse resp = (HttpServletResponse) response;
- String servletPath = req.getRequestURI()
- String servletPath = req.getRequestURL()
req.getRequestURL()----->http://localhost:8080/test/test.jsp
其他方法:
basePath:http://localhost:8080/test/
getContextPath:/test
getServletPath:/test.jsp
getRealPath:D:\Tomcat 6.0\webapps\test\
getServletContext().getRealPath:D:\Tomcat 6.0\webapps\test\
getQueryString:name=wf