实现多个JSP页面共用一个菜单
将菜单栏代码独立为一个jsp页面
1 <%@ page language="java" contentType="text/html; charset=UTF-8" 2 pageEncoding="UTF-8"%> 3 <nav class="navbar navbar-inverse navbar-fixed-top"> 4 <div class="container"> 5 <div class="navbar-header"> 6 <button type="button" class="navbar-toggle collapsed" 7 data-toggle="collapse" data-target="#navbar" aria-expanded="false" 8 aria-controls="navbar"> 9 <span class="sr-only">Toggle navigation</span> <span 10 class="icon-bar"></span> <span class="icon-bar"></span> <span 11 class="icon-bar"></span> 12 </button> 13 <a class="navbar-brand" href="#">商城系统</a> 14 </div> 15 <div id="navbar" class="collapse navbar-collapse"> 16 <ul class="nav navbar-nav"> 17 <li class="dropdown"><a href="showgoods.do" >商城首页</a></li> 18 <li class="dropdown"><a href="#" class="dropdown-toggle" 19 data-toggle="dropdown" role="button" aria-haspopup="true" 20 aria-expanded="false">分类 <span class="caret"></span></a> 21 <ul class="dropdown-menu"> 22 <li><a href="categoryList.do">所有分类</a></li> 23 <li><a href="category/add.jsp">添加分类</a></li> 24 </ul></li> 25 <li class="dropdown"><a href="#" class="dropdown-toggle" 26 data-toggle="dropdown" role="button" aria-haspopup="true" 27 aria-expanded="false">商品 <span class="caret"></span></a> 28 <ul class="dropdown-menu"> 29 <li><a href="addgoods.jsp">添加商品</a></li> 30 <li><a href="querygoods.do">所有商品</a></li> 31 </ul></li> 32 </ul> 33 34 <ul class="nav navbar-nav navbar-right"> 35 <li class="dropdown"><a href="#" class="dropdown-toggle" 36 data-toggle="dropdown" role="button" aria-haspopup="true" 37 aria-expanded="false">${sessionScope.user.username} <span 38 class="caret"></span></a> 39 <ul class="dropdown-menu"> 40 <li><a href="logout.do">退出</a></li> 41 </ul></li> 42 </ul> 43 </div> 44 </div> 45 </nav>