1.首先将菜单栏代码独立为一个jsp页面
例如
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed"
data-toggle="collapse" data-target="#navbar" aria-expanded="false"
aria-controls="navbar">
<span class="sr-only">Toggle navigation</span> <span
class="icon-bar"></span> <span class="icon-bar"></span> <span
class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">商城系统</a>
</div>
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li class="dropdown"><a href="showgoods.do" >商城首页</a></li>
<li class="dropdown"><a href="#" class="dropdown-toggle"
data-toggle="dropdown" role="button" aria-haspopup="true"
aria-expanded="false">分类 <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="categoryList.do">所有分类</a></li>
<li><a href="category/add.jsp">添加分类</a></li>
</ul></li>
<li class="dropdown"><a href="#" class="dropdown-toggle"
data-toggle="dropdown" role="button" aria-haspopup="true"
aria-expanded="false">商品 <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="addgoods.jsp">添加商品</a></li>
<li><a href="querygoods.do">所有商品</a></li>
</ul></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li class="dropdown"><a href="#" class="dropdown-toggle"
data-toggle="dropdown" role="button" aria-haspopup="true"
aria-expanded="false">${sessionScope.user.username} <span
class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="logout.do">退出</a></li>
</ul></li>
</ul>
</div>
</div>
</nav>
2.用jsp内部标签引入菜单栏
<jsp:include page="文件名.jsp" />