我正在将 Web 应用程序移至 Websphere 7,但我的 JSP 页面遇到错误。
JSPG0227E: Exception caught while translating /WEB-INF/jsp/snet/destinationTripReport.jsp:
/WEB-INF/jsp/snet/destinationTripReport.jsp(211,8) --> JSPG0122E: Unable to parse EL function ${destForm.flightTable.get(loop.index).tripId}.
JSP 中出现错误的部分如下所示。
<c:forEach items="${destForm.flightTable}" var="entry" varStatus="loop">
<!-- content -->
<tr class="table-info">
<td>${destForm.flightTable.get(loop.index).tripId}</td>
<td>${destForm.flightTable.get(loop.index).actualArrival}</td>
<td>${destForm.flightTable.get(loop.index).comment}</td>
</tr>
</c:forEach>
最令我困惑的是,它使用 TOMCAT 运行,但在使用 Websphere 时发生错误。
最佳答案
问题
Websphere 7 使用 JSP 2.1 (Java EE5)。 JSP 2.1 不支持 EL 表达式内的方法调用,因此 ${destForm.flightTable.get(loop.index)}
由于在 EL 表达式中调用了 get(),因此无效。
解决方案:
为了解决您的问题,您的 EL 表达式应该是 ${destForm.flightTable[loop.index].tripId}
假设 destForm.flightTable
是一个列表/数组可以通过索引访问。
注意:JSP 2.2+ (Java EE6+) 允许像您一样在 EL 表达式中调用方法。
关于java - JSPG0122E : Unable to parse EL function in Websphere 7,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20844130/