地址分类
绝对地址: 带有协议名称的是绝对地址,http:/ /www.baidu.com , ftp://202.122.23.1
相对地址: 没有协议开头的,例如user/some.do. ,/user/some . do
- 相对地址不能独立使用,必须有一个参考地址。
- 通过参考地址+相对地址本身才能指定资源。
参考地址:在你的页面中的,访问地址不加"/"
举例
访问页面 :http://localhost:8888/springmvc04/index.jsp
上述地址中路径为:http://localhost:8888/springmvc04/
资源为:index.jsp
(1)在index.jsp页面中发起 user/login请求,访问地址变为http://localhost:8888/springmvc04/user/login(绝对地址),访问地址为当前项目地址加上链接的地址:http://localhost:8888/springmvc04/ (参考地址) + user/login(相对地址)
(2)在index.jsp页面中发起 /user/login请求,访问地址变为http://localhost:8888/user/login(绝对地址),访问地址为服务器地址加上链接的地址:http://localhost:8888/ (参考地址) + user/login(相对地址)
(3)EL表达式(推荐使用):"${pageContext.request.contextPath}/user/login"等价于"springmvc04/user/login"
在index.jsp页面中发起 ${pageContext.request.contextPath}/user/login请求,访问地址会变为http://localhost:8888/springmvc04/user/login(绝对地址),访问地址为服务器地址加上链接的地址:http://localhost:8888/ (参考地址) + springmvc04/user/login(相对地址)