首页 > 代码库 > 在用 <%@include file="date.jsp" %> "date.jsp"老提示出错,错误为: Multiple annotations found at this line: - Duplicate local variable path - Duplicate local variable basePath 该怎么解决呢?
在用 <%@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" />是先编译后包含,比较高级。它先把包含的文件编译好送到被包航文件中显示。另外,该指令还可以传递参数。
在用 <%@include file="date.jsp" %> "date.jsp"老提示出错,错误为: Multiple annotations found at this line: - Duplicate local variable path - Duplicate local variable basePath 该怎么解决呢?
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。