在用 <%@include file="date.jsp" %> "date.jsp"老提示出错,错误为: Multiple annotations found at this line: - Duplicate local variable path - Duplicate local variable basePath 该怎么解决呢?

重复变量

date.jsp文件内部不应该再出现重复的变量定义

也就是<%@include%>是先把文件源代码一模一样的拷贝过来,然后才开始编译
所以如果有相同的变量肯定报错

用了动态的<jsp: include file="top.jsp" />的就正确了

因为<%@include%>引进的是代码,把代码包含进来,而新进JSP时,会默认生成

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

该指令功能很死板!它是先包含后编译,如果在包含文件中和被包含文件中都有同名变量的定义(例如两文件中都定义了int a = 0;),那就会出现“重复的变量定义 ”的错误,

<jsp: include file="date.jsp" />是先编译后包含,比较高级。它先把包含的文件编译好送到被包航文件中显示。另外,该指令还可以传递参数。

时间: 2024-08-11 09:53:16

在用 <%@include file="date.jsp" %> "date.jsp"老提示出错,错误为: Multiple annotations found at this line: - Duplicate local variable path - Duplicate local variable basePath 该怎么解决呢?的相关文章

jsp页面提示“Multiple annotations found at this line: - The superclass &quot;javax.servlet.http.HttpServlet&quot; was not found on the Java Build Path”解决方案

Multiple annotations found at this line: - The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path 新建jsp页面老提示: Multiple annotations found at this line: - The superclass "javax.servlet.http.HttpServlet" was

eclipse新建JSP页面报错:Multiple annotations found at this line解决方法

错误提示: Multiple annotations found at this line: - The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path - The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path 错误原因:缺少编译JSP页面

JSP 使用&lt;%@include%&gt;报Duplicate local variable path 错误 解决方法

错误提示:Multiple annotations found at this line:- Duplicate local variable path- Duplicate local variable basePath 重复变量,因为<%@include%>引进的是代码,把代码包含进来,而新进JSP时,会默认生成<%String path = request.getContextPath();String basePath = request.getScheme()+":/

【JSP】JSP指令

JSP指令 说明: 1.JSP指令用于告知JSP 引擎转译JSP时的转化参数,他们不产生输出信息,只是在JSP的转译和编译期间起作用. 2.JSP指令必须写在规定的格式中:  <%@  [goes here]  %> 3.除了include指令外,page 和 taglib指令都必须写在JSP文件的开始处. JSP指令主要有3个    page , include , taglib ,下面一 一介绍 page 指令 page指令由很多k-v形式的属性构成,除了import属性外,其它的属性都只

jsp的静态包含与动态包含:&lt;%@ include file=&quot;&quot; %&gt;和&lt;jsp:include page=&quot;&quot;&gt;&lt;/jsp:include&gt;区别与分析

<%@ include file="" %>是将文件原封不动的copy进现有的文件中,像是拼接好后,再编译成为servlet运行. <jsp:include page=""></jsp:include>是编译后的servlet运行到该句时,跳转到指定的jsp编译的那个servlet继续运行,然后将运行结果,copy到现在的jsp中,故包含与被包含文件都是单独运行的. 在开发过程中,我们需要正确选择使用.举个例子: 比如在工程项目中

jsp的&lt;%@ include file=&quot;jsp/common.jsp&quot; %&gt;报错误Duplicate local variable basePath

将公共引入的文件放到common.jsp中,其他页面引入该jsp即可使用 1 <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> 2 <% 3 String path = request.getContextPath(); 4 String basePath = request.getScheme() + "://" 5 +

&lt;jsp:include page=&quot;&quot;&gt;和&lt;%@ include file=&quot;&quot;%&gt;区别总结

<jsp:include page="">和<%@ include file=""%>区别总结 1:<jsp:include page="top.jsp">:先将top.jsp中的java脚本和jsp指令都执行完毕以后再将top.jsp页面加入到引用页面中. 2:<%@ include file="top.jsp"%>静态读取:则是将top.jsp的整个页面不加解析(无论是脚本还

关于&lt;%@ include file=&quot; &quot; %&gt;与&lt;jsp:include page=&quot;&quot;&gt;&lt;/jsp:include&gt;中的那些问题?

今天在使用<%@ include file=" " %>指令时,竟然在页面中不让使用?这是怎么回事:问题如下图: 顿时被这个问题给搞到了!!!突然想到在以前的 JSP 页面中就可以使用,而这是为什么?然后再进行查看时发现,原来是因为以前我为了方便而修改了创建 JSP 模版文件,我在文件上添加了如下代码: <%String path = request.getContextPath();String basePath = request.getScheme()+&quo

&lt;jsp:include page=&quot;index.jsp&quot;&gt;和&lt;%@include file=&quot;index.jsp&quot; %&gt;的区别

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd&quo