Put the publicly introduced files into the common.jsp, and the other pages introduce the JSP to use
1 <%@ Page Language="Java"Import="java.util.*"pageencoding="UTF-8"%>2 <%3 StringPath=Request.getcontextpath ();4 StringBasePath=Request.getscheme ()+ "://"5 +Request.getservername ()+ ":" +Request.getserverport ()6 +Path+ "/";7 %>8 <!DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en">9 <HTML>Ten <Head> One <Basehref= "<%=basePath%>"> A <%@ include file="jsp/common.jsp" %> - <title>My JSP ' index.jsp ' starting page</title> - </Head>
This report: Duplicate local variable BasePath
Because <%@ include file= "jsp/common.jsp"%> is the file specified page code is completely put into your page, so that the equivalent of two statements
<base href= "<%=basePath%>", so reported a duplicate error.
Analysis: <%@ include file= ""%> and <jsp:include page= "></jsp:include> Differences and analysis
<%@ include file= ""%> is to copy files intact into the existing file, such as stitching, and then compiled into a servlet run.
<jsp:include page= "" ></jsp:include> is the compiled servlet running to that sentence, jump to the specified JSP compiled by the servlet to continue running, and then run the result, Copy to the current JSP, so that the inclusion and the included files are run separately.
Workaround: In order to achieve the goal, we can only declare the introduction of the file to be used in a JSP file, without having to specify base, and so on, as follows:
<Scripttype= "Text/javascript"src= "Js/alert.js"CharSet= "UTF-8"></Script><Scripttype= "Text/javascript"src= "Js/jquery-easyui-1.4.1/jquery.easyui.min.js"CharSet= "UTF-8"></Script><Scripttype= "Text/javascript"src= "Js/jquery-easyui-1.4.1/jquery.min.js"CharSet= "UTF-8"></Script><Scripttype= "Text/javascript"src= "Js/jquery-easyui-1.4.1/locale/easyui-lang-zh_cn.js"CharSet= "UTF-8"></Script><Linkrel= "stylesheet"href= "Js/jquery-easyui-1.4.1/themes/icon.css"type= "Text/css"CharSet= "UTF-8"></Link><Linkrel= "stylesheet"href= "Js/jquery-easyui-1.4.1/themes/color.css"type= "Text/css"CharSet= "UTF-8"></Link><Linkrel= "stylesheet"href= "Js/jquery-easyui-1.4.1/themes/default/easyui.css"type= "Text/css"CharSet= "UTF-8"></Link>
Where JS and CSS files are webapp to the root to specify the appropriate reference address.
At this point, you can use <%@ include file= "jsp/common.jsp"%> in index.jsp to solve the problem
<%@ Page Language="Java"Import="java.util.*"pageencoding="UTF-8"%><% StringPath=Request.getcontextpath (); StringBasePath=Request.getscheme ()+ "://" +Request.getservername ()+ ":" +Request.getserverport ()+Path+ "/";%><!DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en"><HTML><Head><Basehref= "<%=basePath%>"> <%@ include file="jsp/common.jsp" %> <title>My JSP ' index.jsp ' starting page</title></Head>
JSP <%@ include file= "jsp/common.jsp"%> report error duplicate local variable BasePath