head.jsp文件
将项目中所需要用到次数比较多的的插件,库等,同意放在一个jsp文件里面,命名为head.jsp文件,相当于一个全局的
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!-- 导入标签库 --> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %> <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> <meta charset="utf-8"/> <meta name="renderer" content="webkit"><!--360默认极速模式--> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta content="width=device-width, initial-scale=1.0" name="viewport"/> <meta http-equiv="Content-type" content="text/html; charset=utf-8"> <meta content="" name="description"/> <meta content="" name="author"/> <!-- 设置全局变量 --> <base href="<%=request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()%><c:url value="/"/>"/> <c:set var="ctx" value="${pageContext.request.contextPath}"/> <link href="${ctx}/css/common/font-awesome.min.css" rel="stylesheet" type="text/css" /> <link href="${ctx}/css/common/ionicons.min.css" rel="stylesheet" type="text/css" /> <link href="${ctx}/css/common/AdminLTE.css" rel="stylesheet" type="text/css" /> <link href="${ctx}/css/global/optimize.css" rel="stylesheet" type="text/css" /> <!-- jQuery插件 --> <script src="${ctx}/js/global/jquery/jquery.min.js"></script> <script src="${ctx}/js/global/jquery-file-upload/js/vendor/jquery.ui.widget.js"></script> <script src="${ctx}/js/global/jquery-file-upload/js/jquery.iframe-transport.js"></script> <script src="${ctx}/js/global/jquery-file-upload/js/jquery.fileupload.js"></script> <!-- 日历插件--> <script src="${ctx}/js/global/date/jedate/jedate.js"></script> <!-- bootstrap插件 --> <link href="${ctx}/css/common/bootstrap.min.css" rel="stylesheet" type="text/css" /> <script src="${ctx}/js/global/bootstrap/bootstrap.min.js" type="text/javascript"></script> <!-- 新版 --> <link href="${ctx}/js/global/bootstrap-table/bootstrap-table.min.css" rel="stylesheet"> <script src="${ctx}/js/global/bootstrap-table/bootstrap-table.min.js"></script> <script src="${ctx}/js/global/bootstrap-table/bootstrap-table-zh-CN.min.js"></script> <!--左侧滑动 --> <script src="${ctx}/js/global/AdminLTE/app.js" type="text/javascript"></script> <!-- layer插件 --> <script src="${ctx}/js/global/layer/layer.js" type="text/javascript"></script> <script type="text/javascript"> var pathName=window.document.location.pathname; var ROOT=pathName.substring(0,pathName.substr(1).indexOf('/')+1); </script>
在每个模块的jsp文件里面
不需要在一次引入bootstrap插件,layer插件,jQuery插件,只需要在head和meta之间写上这段代码<%@include file="../include/head.jsp"%> ,引入head.jsp文件即可,简单方面,不需要再一次在每个jsp页面重复引入所需要的或者删掉不需要的,提高了效率。
<head> <!-- 引入各种头文件 --> <%@include file="../include/head.jsp"%> <meta charset="UTF-8">