我的目录项目Explorer
我是JSP中的新手,并尝试链接位于Bootstrap/css/bootstrap.min.css中的bootstrap.min.css文件与位于parts/header.jsp
这是我的代码 Header.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
home.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<jsp:include page ="Parts/Header.jsp"/>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
</body>
</html>
,为了避免相对路径,您必须使用应用程序的te上下文root a/a/perfix启动您的URL。
然后更改:
<link rel="stylesheet" href="/bootstrap/css/bootstrap.min.css">
:
<link rel="stylesheet" href="<%= request.getContextPath() %>/bootstrap/css/bootstrap.min.css">
<style>
<%@ include file="style.css"%>
</style>