Eclipse 中为包含的 JSP 指示“无法解析 someVariable”错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2268153/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
"someVariable cannot be resolved" error indicated in Eclipse for an included JSP
提问by wsams
So I have a main JSP index page, "index.jsp", which has several includes. Something like,
所以我有一个主要的 JSP 索引页面,“index.jsp”,它有几个包含。就像是,
<%@ 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();".
“include.jsp”包含一个字符串“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".
“navbar.jsp”使用“basePath”,但Eclipse 会在“navbar.jsp”的任何使用“basePath”的行上放置一个红色X,并显示“basePath 无法解析”消息。
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".
我的 webapp 工作得很好,但想知道可能是什么原因造成的,或者是否可以解决?或者也许有办法让 Eclipse 忽略这个?我只是想让误报红色 X 消失。我想 Eclipse 不明白“navbar.jsp”正在从“include.jsp”获取“basePath”,因为它是与“index.jsp”一起编译的。
回答by BalusC
Eclipse is an epic failurewith regard to JSP/EL validation. Just ignore it or disable all (or parts of) JSP/EL validation in workspace preferences through Validationand/or Web> JSP Files> Validation.
就 JSP/EL 验证而言,Eclipse 是一个史诗般的失败。只需通过Validation和/或Web> JSP Files> Validation在工作区首选项中忽略它或禁用所有(或部分)JSP/EL 验证。