jsp页面中的path 与 bathPath区别

来源:互联网 发布:大数据板块龙头股票 编辑:程序博客网 时间:2024/06/10 07:38

jsp页面中的path 与 bathPath区别

<%String path = request.getContextPath();String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()+ path + "/";%>

例如项目名称为:  AAA  则

path为:   /AAA

bathPath为  http://localhost:8080/AAA/

其中:

request.getScheme() 为:  http

request.getServerName() 为: localhost

request.getServerPort()  为 :8080


需要返回某个页面时,可以添加如下链接

<a href="<%=basePath%>index.jsp">返回首页</a>