Analysis of jsp interface inheritance or not, jsp INTERFACE ANALYSIS
Page Introduction
$ {PageContext. request. contextPath} is the page context path;
It can also be implemented using js;
<Script type = "text/javascript" src = "$ {pageContext. request. contextPath}/js/student_evaluation/studentInfo. js "> </script> is equivalent to: <script type =" text/javascript "id =" studentInfoJS "> </script> <script type =" text/javascript "> document. getElementById ('studentinfojs '). src = basePath + 'js/student_evaluation/studentInfo. js'; </script>
You can write the following code on the basic page;
Var basePath = "<% = basePath %>"; implements global PATH variables, but $ {pageContext. request. contextPath} can be replaced completely;
<% @ Page language = "java" contentType = "text/html; charset = UTF-8"
PageEncoding = "UTF-8" %>
<% @ Taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "c" %>
<%
String path = request. getContextPath ();
String basePath = request. getScheme () + ": //" + request. getServerName () + ":" + request. getServerPort ()
+ Path + "/";
%>
<! DOCTYPE html>
<Html>
<Script type = "text/javascript">
Var basePath = "<% = basePath %> ";
</Script>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8">
<Title> Student Score Information </title>
<Link rel = "stylesheet" type = "text/css"
Href = "<%= basePath %> jquery/jquery. bsgrid-1.37/builds/merged/bsgrid.all.min.css">
<Script type = "text/javascript"
Src = "<% = basePath %> jquery/jquery-1.12.3.min.js"> </script>
<Script type = "text/javascript"
Src = "<% = basePath %> jquery/jquery. bsgrid-1.37/builds/js/lang/grid. zh-CN.min.js"> </script>
<Script type = "text/javascript"
Src = "<% = basePath %> jquery/jquery. bsgrid-1.37/builds/merged/bsgrid. all. min. js"> </script>
<Script type = "text/javascript" src = "<% = basePath %> jquery/jquery. bsgrid-1.37/builds/js/util. min. js"> </script>
</Head>
<Body>
</Body>
</Html>
Use the following statement:
<jsp:include page="/view/base.jsp" flush="true" />
The critical moment should be as follows:
<script type="text/javascript"> var pp = "${pageContext.request.contextPath}"; alert(pp);</script>
However, the introduced js file does not have a value, so inheritance is necessary.
Well, write it here first. If you have any questions, please contact us!