0

我在 JSP 标记中有一些 EL 代码。该行开始如下:

<c:if test="${pageContext.request.serverName eq \'localhost\'}">

Eclipse 对此抛出了一个错误,说:

由于词法分析错误,无法分析 EL 表达式

我不确定这甚至意味着什么。这是一个日食错误吗?我是否错误地混合了 EL 和 JSTL 标签?

4

1 回答 1

1

只需不带反斜杠即可:

${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}" 显示什么?

于 2010-05-17T14:41:39.990 回答