如何在 Eclipse 的 jsp 片段文件中抑制警告(甚至错误)?
我在 jsp 文件的中间包含了这个 jspf,但是该 jspf 在包含之前依赖于代码中更靠前的变量。然而,即使一切正常,每次我验证我的代码(在部署之前)时,Eclipse 都会将该 jspf 标记为错误。我可以放心地忽略该错误并继续部署,但是有没有办法通过该 jspf 文件中的抑制警告注释来消除该错误?
主.jsp:
<%
String someVariable = "foo.bar";
%>
<% @ include file="WEB-INF/jspf/sample.jspf" %>
WEB-INF/jspf/sample.jspf
<%
// shows unresolved local variable error when validated
// but can still deploy just fine if error is ignored
if(someVariable != null && someVariable.length() > 0)
out.println(someVariable);
%>
上面的例子很简单,但是 sample.jspf 永远不会直接从 URL 调用。它将始终包含在其他一些 jsp 文件中。现在如何在验证时删除 Eclipse 中的错误标记?