gpt4 book ai didi

JSP 错误 : contains invalid expression. 解析表达式失败

转载 作者:行者123 更新时间:2023-12-03 22:48:31 28 4
gpt4 key购买 nike

我正在尝试调试旧的 jsp 站点,因此我在运行 Windows 7 的本地计算机上安装了 tomcat 7 和 Netbeans IDE 7.2.1 并设置了所有内容。但是当我运行它时,我收到一个错误:

SEVERE: Servlet.service() for servlet jsp threw exception org.apache.jasper.JasperException: /pages/caselisting.jsp (line: 133, column: 35) "${case.patientmaxdate}" contains invalid expression(s): javax.el.ELException: Failed to parse the expression [${case.patientmaxdate}]



该行的代码是:
<td><c:out default="&nbsp;" escapeXml="false" value="${case.patientmaxdate}"/></td>

我对 jsp 很陌生,正在尝试对这个旧站点进行一些更改。我做了一些研究并了解到 Tomcat 7 对这个错误做了一些更改。如果有人能指导我朝着正确的方向前进,我将不胜感激。

谢谢。

完整的堆栈跟踪:

SEVERE: Servlet.service() for servlet jsp threw exception org.apache.jasper.JasperException: /pages/caselisting.jsp (line: 133, column: 35) "${case.patientmaxdate}" contains invalid expression(s): javax.el.ELException: Failed to parse the expression [${case.patientmaxdate}] at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:42) at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:408) at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:199) at org.apache.jasper.compiler.Validator$ValidateVisitor.checkXmlAttributes(Validator.java:1223) at org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:875) at org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1539) at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376) at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2428) at org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:894) at org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1539) at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376) at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2428) at org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2434) at org.apache.jasper.compiler.Node$Root.accept(Node.java:475) at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376) at org.apache.jasper.compiler.Validator.validateExDirectives(Validator.java:1795) at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:217) at org.apache.jasper.compiler.Compiler.compile(Compiler.java:373) at org.apache.jasper.compiler.Compiler.compile(Compiler.java:353) at org.apache.jasper.compiler.Compiler.compile(Compiler.java:340) at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:646) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334) at javax.servlet.http.HttpServlet.service(HttpServlet.java:728) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:749) at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:487) at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:412) at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:339) at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1056) at org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:261) at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:388) at org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:316) at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:231) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164) at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:397) at javax.servlet.http.HttpServlet.service(HttpServlet.java:621) at javax.servlet.http.HttpServlet.service(HttpServlet.java:728) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at filter.SecureFilter.doFilter(SecureFilter.java:38) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589) at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1822) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) at java.lang.Thread.run(Thread.java:722)



围绕错误行的完整代码是:
 <c:forEach items="${caselist}" var="case">
<tr onMouseOver="this.bgColor='#EEEEEE';" onMouseOut="this.bgColor='';">
<td><c:out default="&nbsp;" escapeXml="false" value="${case.patientmaxdate}"/></td>

这里 caselist 是一个数组列表。

最佳答案

不确定你是否最终解决了这个问题,但刚刚遇到了类似的问题并解决了它,我想我会插手。

Tomcat 7 中的表达式解析器显然不像以前的版本那样宽松。它不喜欢 EL 表达式中的属性名称与 Java 中的保留关键字冲突。

在您的示例中,解析器可能会提示您在 forEach 循环中使用了变量名称“case”。名称“case”显然是保留的 Java 关键字。

您应该将变量名称更改为不保留的名称(可能是“aCase”):

<c:forEach items="${caselist}" var="aCase">
<tr onMouseOver="this.bgColor='#EEEEEE';" onMouseOut="this.bgColor='';">
<td><c:out default="&nbsp;" escapeXml="false" value="${aCase.patientmaxdate}"/>

或者,您可以设置一个系统属性,使 Tomcat 7 更加宽容:
-Dorg.apache.el.parser.SKIP_IDENTIFIER_CHECK=true

您需要将其添加到 Tomcat 7 属性窗口(运行 Tomcat7w.exe)的 Java 选项框中的属性列表的末尾。

enter image description here

这将适用于您在 Tomcat 7 中运行的所有应用程序中的所有页面。

关于JSP 错误 : contains invalid expression. 解析表达式失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14655014/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com