“someVariable不能解决”包含的JSP在Eclipse中显示错误 [英] "someVariable cannot be resolved" error indicated in Eclipse for an included JSP

查看:145
本文介绍了“someVariable不能解决”包含的JSP在Eclipse中显示错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有一个主要的JSP索引页,index.jsp,它有几个包括。例如,

 <%@ include file =/ WEB-INF / views / includes / jstl / include.jsp %GT; 
<%@ include file =/ WEB-INF / views / includes / licenses / license.jsp%>
<%@ include file =/ WEB-INF / views / includes / generalHtml / header.jsp%>
<%@ include file =/ WEB-INF / views / includes / navigation / navbar.jsp%>
<%@ include file =/ WEB-INF / views / includes / generalHtml / footer.jsp%>

include.jsp包含一个字符串String basePath = request.getContextPath();。



navbar.jsp使用basePath,但Eclipse在使用basePath的任何navbar.jsp行上放置一个红色的X,消息为basePath不能解决。



我的webapp工作得很好,但是想知道可能导致什么,还是可以解决?或者也许有一种方法让Eclipse忽略这个?我只是想要虚假的红色X的消失。我想Eclipse不明白navbar.jsp从include.jsp获得basePath,因为它与index.jsp一起编译。

解决方案

Eclipse是一个史诗故障关于JSP / EL验证。只需忽略它,或通过验证和/或 Web > JSP文件> 禁用工作区首选项中的所有(或部分)JSP / EL验证em>验证。


So I have a main JSP index page, "index.jsp", which has several includes. Something like,

<%@ include file="/WEB-INF/views/includes/jstl/include.jsp" %>
<%@ include file="/WEB-INF/views/includes/licenses/license.jsp" %>
<%@ include file="/WEB-INF/views/includes/generalHtml/header.jsp" %>
<%@ include file="/WEB-INF/views/includes/navigation/navbar.jsp" %>
<%@ include file="/WEB-INF/views/includes/generalHtml/footer.jsp" %>

The "include.jsp" contains a string "String basePath = request.getContextPath();".

"navbar.jsp" uses "basePath", but Eclipse puts a red X on any line of "navbar.jsp" that uses "basePath" with the message "basePath cannot be resolved".

My webapp works just fine, but wondering what might be causing this, or if it can be resolved? Or maybe there's a way to make Eclipse ignore this? I just want the false positive red X's to go away. I suppose Eclipse doesn't understand that "navbar.jsp" is getting "basePath" from "include.jsp" because it is compiled together with "index.jsp".

解决方案

Eclipse is an epic failure with regard to JSP/EL validation. Just ignore it or disable all (or parts of) JSP/EL validation in workspace preferences through Validation and/or Web > JSP Files > Validation.

这篇关于“someVariable不能解决”包含的JSP在Eclipse中显示错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆