错误提示:Multiple annotations found at this line: basePath cannot be resolved to a variable
2017-10-12 17:11
981 查看
出现以上错误,主要是由下面这句引起的:<base href="<%= basePath %>">
但这句话似乎又没有任何问题。将这句话删除问题就得到了解决,而且对原来的网站没有影响。
经过在网上一番查找,总结如下:这个错误出现的原因是由自己在做jsp文件引入时引起的,文件加载合并过程中出现了代码加载重复的现象。经过阅读下面的文档则恍然大悟,原来自己删了JSP页面开头的代码,才会出现这样的问题。将源代码进行恢复则问题得到解决。
JSP中<base href="<%=basePath%>">作用通常在JSP页面开头有如下代码:
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
这段代码的意思是获取当前项目的路径,如:http://localhost:8080/项目名称。
在<head></head>中通常有如下代码:
<base href="<%=basePath%>">
这是设置基础路径的,basePath为变量,简单的静态网页的话你设置比如:<base href="http://www.baidu.com">,那你下面的href属性就会以你上面设的为基准,如:<a href="http://www.baidu.com/xxx.htm"></a>你现在就只需要写<a href="xxx.htm"></a>
但这句话似乎又没有任何问题。将这句话删除问题就得到了解决,而且对原来的网站没有影响。
经过在网上一番查找,总结如下:这个错误出现的原因是由自己在做jsp文件引入时引起的,文件加载合并过程中出现了代码加载重复的现象。经过阅读下面的文档则恍然大悟,原来自己删了JSP页面开头的代码,才会出现这样的问题。将源代码进行恢复则问题得到解决。
附:
JSP中<base href="<%=basePath%>">作用通常在JSP页面开头有如下代码:<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
这段代码的意思是获取当前项目的路径,如:http://localhost:8080/项目名称。
在<head></head>中通常有如下代码:
<base href="<%=basePath%>">
这是设置基础路径的,basePath为变量,简单的静态网页的话你设置比如:<base href="http://www.baidu.com">,那你下面的href属性就会以你上面设的为基准,如:<a href="http://www.baidu.com/xxx.htm"></a>你现在就只需要写<a href="xxx.htm"></a>
相关文章推荐
- 网站开发进阶(十六)错误提示:Multiple annotations found at this line:- basePath cannot be resolved to a variable
- 网站开发进阶(十六)错误提示:Multiple annotations found at this line:- basePath cannot be resolved to a variable
- Eclipse的JSP页面提示Multiple annotations found at this line或者String cannot be resolved to a type
- Eclipse的JSP页面提示Multiple annotations found at this line或者String cannot be resolved to a type
- Eclipse的JSP页面提示Multiple annotations found at this line或者String cannot be resolved to a type
- Multiple annotations found at this line: - javax.servlet.jsp.PageContext cannot be resolved to a typ
- Multiple annotations found at this line: - String cannot be resolved to a type - The method getConte
- Multiple annotations found at this line: - String cannot be resolved to a type
- Multiple annotations found at this line: - String cannot be resolved to a type
- jsp页面老提示Multiple annotations found at this line: - javax.servlet.jsp.JspException cannot be resolve
- MyEclipse中出现Multiple annotations found at this line: - Syntax error, insert "}" to complete 错误解决方法
- MyEclipse中出现Multiple annotations found at this line: - Syntax error, insert "}" to complete 错误解决方法
- android Multiple markers at this line - The type java.lang.Class cannot be resolved. It is indirectl
- jsp页面提示“Multiple annotations found at this line: - The superclass "javax.servlet.http.HttpServlet" w
- android Multiple markers at this line - The type java.lang.Class cannot be resolved. It is indirectl
- android Multiple markers at this line - The type java.lang.Class cannot be resolved. It is indirectl
- Multiple annotations found at this line: - Consider adding android:paddingEnd="10dp" to better supp
- 解决eclipse Multiple annotations found at this line 错误
- Multiple annotations found at this line: - cvc-elt.1: Cannot find the declaration of element 'ehcac
- 解决Multiple annotations found at this line: - schema_reference.4: Failed to read schema document '