方法一
<%
String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath() + "/";
%>
<head>
<base href="<%=basePath%>">
<script type="text/javascript" src="js/*.js"></script>
</head>
<img src="<%=basePath>/image/1.png">
方法二
<img src="${pageContext.request.contextPath}/images/logo.jpg"></a>
jsp中base标签的两种使用方法
最新推荐文章于 2021-02-04 11:36:56 发布
本文介绍了两种在网页中配置资源路径的方法:一种使用 JSP 表达式语言设置 base 标签的 href 属性;另一种直接在 img 标签中指定相对路径。这两种方法能够帮助开发者更灵活地管理网站资源,确保链接正确且易于维护。
538

被折叠的 条评论
为什么被折叠?



