错误提示:
Multiple annotations found at this line:
- Duplicate local variable path
- Duplicate local variable
basePath
因为<%@include%>引进的是代码,把代码包含进来,而新进JSP时,会默认生成
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<base href="<%=basePath%>">
这二句代码,所以用<%@include%>引进页面是就报重复变量 basePath
解决方法,把要引进页面这句去掉就行,一开始我也懵逼了
有2个解决的方法
1.重命名path和basePath变量
2.要不引用path,直接用request.getContextPath();

本文探讨了在使用<%@include%>引入代码时遇到的重复变量basePath问题,并提供了两种解决策略:一是重命名变量,二是直接使用request.getContextPath()方法。
1668

被折叠的 条评论
为什么被折叠?



