Set global reference file in jsp page

head.jsp file

The plug-ins, libraries, etc. that need to be used more often in the project are agreed to be put in a JSP file named head.jsp file, which is equivalent to a global

<%@ page language="java" contentType="text/html; charset=UTF-8"
   pageEncoding="UTF-8"%>
<!-- Import label Library -->
<%@ 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 Default speed mode-->
<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"/>

<!-- Set global variables -->
<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 Plug-in unit -->
<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>

<!--  Calendar plug-in-->
<script  src="${ctx}/js/global/date/jedate/jedate.js"></script>

<!-- bootstrap Plug-in unit -->
<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>


<!-- new edition -->
<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> 


<!--Left sliding -->
<script src="${ctx}/js/global/AdminLTE/app.js" type="text/javascript"></script>

<!-- layer Plug-in unit -->
<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>

In the jsp file of each module
It is not necessary to introduce bootstrap plug-in, layer plug-in and jQuery plug-in at one time. It is only necessary to write this code between head and meta <% @ include file = ".. / include / head. JSP"% > and introduce head.jsp file. In simple aspect, it is not necessary to repeatedly import or delete what is not needed in each JSP page, which improves efficiency.

<head>
<! -- import various header files -- >
<%@include file="../include/head.jsp"%> 
<meta charset="UTF-8">

Keywords: JSP JQuery Javascript Java

Added by wizhippo on Tue, 31 Mar 2020 19:39:44 +0300