上图是一个测试页面,WEB-INF/web/webinf.jsp 里面引用 images/start.jpg
<%
String path = request.getContextPath();
request.setAttribute("path", path);
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<base href="<%=basePath%>">
在jsp里面我已经将基路径给注释掉了,但是还是可以正确引用到images/start.jpg 图片,正常引用应该是
src="../images/start.jpg"
如果将webinf.jsp放到web_root/jsp/webinf.jsp时
就可以测试跳转和重定向访问webinf.jsp页面时引用的区别了,
总结一句话: