首先导入bootstrap的css和js
<link href="bootstrap5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="bootstrap5.1.3/dist/js/bootstrap.bundle.min.js"></script>
top.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
</head>
<body>
<%--导航栏--%>
<nav class="navbar navbar-dark bg-primary mb-2">
<div class="container-fluid">
<a class="navbar-brand" href="#">
天天商城
</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#linkText"
aria-controls="navbarText" aria-expanded="false">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="linkText">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link" href="index.jsp" id="index">首页</a>
</li>
<li class="nav-item">
<a class="nav-link" href="insert.jsp" id="insert">增加商品</a>
</li>
</ul>
<script>
$("#<%=request.getParameter("type")%>").addClass("active")
</script>
</div>
</div>
</nav>
</body>
</html>