1 Preface
People who do Java development may know that there are two ways to introduce other files in a project in a JSP
<% @include file= "xxx.jsp"%>
<jsp:include page= "xxx.jsp" ></jsp:include>
We may use both approaches, but perhaps many people do not name the difference between the two ways. Let's take a look at the following two examples
2 straight to the question
(1)/include/include.jsp
<%@ page language= "java" pageencoding= "UTF-8"%>
<%
String path = Request.getcontextpath ();
%>
<p>include Page </p>
(2)/index1.jsp page
<%@ page language= "java" pageencoding= "UTF-8"%>
<%
String path = Request.getcontextpath ();
%>
<! DOCTYPE html>
(3)/index2.jsp
<%@ page language= "java" pageencoding= "UTF-8"%>
<%
String path = Request.getcontextpath ();
%>
<! DOCTYPE html>
Now we have access to index1.jsp and the results are as follows
Then we continue to visit index2.jsp, and the results are as follows
Why, how index1.jsp why visit the error, ah, it seems @include and Jsp:include is a difference. Only by understanding the bottom difference between @include and jsp:include, we know why the index1.jsp page is wrong. Please keep looking and you will understand.
This column more highlights: http://www.bianceng.cn/webkf/JSP/