EL表达式

Posted toohoo

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了EL表达式相关的知识,希望对你有一定的参考价值。

初学javaweb,EL表达式犯了一个好笑的错误

org.apache.jasper.JasperException: An exception occurred processing JSP page /dept/listDept.jsp at line 38

35:       <c:forEach items="${dept}" var="dep" varStatus="varSta">
36:       <tr>
37:           <td>${varSta.count }</td>
38:           <td>${dept.deptNo }</td>
39:           <td>${dept.deptName }</td>
40:           <td>${dept.loc }</td>
41:           <td>


Stacktrace:
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:568)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:470)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
    cn.edu.lingnan.servlet.ListDeptServlet.doGet(ListDeptServlet.java:31)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
root cause

java.lang.NumberFormatException: For input string: "deptNo"
    java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
    java.lang.Integer.parseInt(Integer.java:492)
    java.lang.Integer.parseInt(Integer.java:527)
    javax.el.ListELResolver.coerce(ListELResolver.java:173)
    javax.el.ListELResolver.getValue(ListELResolver.java:52)
    org.apache.jasper.el.JasperELResolver.getValue(JasperELResolver.java:104)
    org.apache.el.parser.AstValue.getValue(AstValue.java:183)
    org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:185)
    org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:1026)
    org.apache.jsp.dept.listDept_jsp._jspx_meth_c_005fforEach_005f0(listDept_jsp.java:154)
    org.apache.jsp.dept.listDept_jsp._jspService(listDept_jsp.java:105)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
    cn.edu.lingnan.servlet.ListDeptServlet.doGet(ListDeptServlet.java:31)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:728)

出错的地方是:

35:       <c:forEach items="${dept}" var="dep" varStatus="varSta">
36:       <tr>
37:           <td>${varSta.count }</td>
38:           <td>${dept.deptNo }</td>
39:           <td>${dept.deptName }</td>
40:           <td>${dept.loc }</td>
41:           <td>

将dept改成dep就好了。

以上是关于EL表达式的主要内容,如果未能解决你的问题,请参考以下文章

jsp--EL表达式

jsp中的EL表达式

Jsp入门EL表达式_学习笔记

第五条知识点

EL表达式

EL表达式的基本知识