我在 JSP 标记内有一些 EL 代码。该行的开头如下:
<c:if test="${pageContext.request.serverName eq \'localhost\'}">
Eclipse 会抛出一个错误,指出:
Unable to analyze EL expression due to lexical analysis error
我不确定这意味着什么。这是 eclipse 错误吗?我是否错误地混合了 EL 和 JSTL 标签?
最佳答案
不用反斜杠即可:
${pageContext.request.serverName eq 'localhost'}
包含该代码的 JSP:
${pageContext.request.serverName eq 'localhost'}
<c:if test="${pageContext.request.serverName eq 'localhost'}">faith</c:if>
为我呈现“真正的信仰”。 “${pageContext.request.serverName}”显示什么?
关于java - jsp EL验证中eclipse出现词法分析错误是什么原因?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2849930/