前沿,在网页开发中,总会存在某几个.js或者某几个.css是所有.jsp文件的公用文件,为了方便引用
我们把这些在公共的.js及.css文件放到一个.jsp文件中,只需要将这个引入所有公共.js及.css的文件放到需要用到的.jsp文件中即可
例如:
head.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/css/noticeService/loadingAndMsg.css" /> <script type="text/javascript" src="<%=request.getContextPath() %>/js/public/jquery.js"></script> <script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script> </head>
children.jsp
<%@ include file="/wsp/include/head.jsp" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="keywords" content=""> <title>百万家财燃气保-宿享版</title> </head> <body> <div class="container">该页面引用了公共.js及.css</div> </body> </html>