小tips:tomcat下JSP页面引用css、js等资源路径404问题
在JSP页面头部添加如下代码:
<% String path = request.getContextPath(); String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/"; %>
在引用资源前面添加如下代码:
<base href="<%=basePath%>"> <link rel="stylesheet" type="text/css" href="./resource/base.css"> <link rel="stylesheet" type="text/css" href="./resource/common.css">