jsp中文件路径

来源:互联网 发布:欧洲历史书籍推荐知乎 编辑:程序博客网 时间:2024/05/21 02:21

加斜杠是绝对路径,基于http://localhost:8080/
不加斜杠是相对路径,基于当前文件
如果设置了basePath,就基于basePath

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

绝对路径:${pageContext.request.contextPath}取出部署的应用程序名

原创粉丝点击