<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<head>
<base href="<%=basePath%>">
<link href="assets/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css"/>
</head>

配置了绝对路径,页面就可直接使用webapp的文件路径等。
本文介绍了一种在Web应用程序中设置绝对路径的方法,通过在JSP页面中使用request对象获取上下文路径和服务器信息,从而实现对webapp内部文件路径的直接调用,确保资源链接的正确性和稳定性。
247

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



