javax.servlet.jsp.JspTagException: Don't know how to iterate over supplied "items" in xxx
今天使用SringMVC + Mybatis + JSP 搭建一個小 demo 的時候,報瞭如下錯誤
報錯資訊如下
type Exception report
message An exception occurred processing JSP page /WEB-INF/views/user_list.jsp at line 28
description The server encountered an internal error that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: An exception occurred processing JSP page /WEB-INF/views/user_list.jsp at line 28
25: <th>鍒犻櫎</th>
26: </tr>
27: </thead>
28: <c:forEach items="${user}" var="user">
29: <tr>
30: <th>${user.id}</th>
31: <th>${user.name}</th>
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:574 )
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:461)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52 )
org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:170)
org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:314)
org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1325)
org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1069)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1008)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:925)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:974)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:877)
javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:851)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
root cause
javax.servlet.ServletException: javax.servlet.jsp.JspTagException: Don't know how to iterate over supplied "items" in <forEach>
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:909)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:838)
org.apache.jsp.WEB_002dINF.views.user_005flist_jsp._jspService(user_005flist_jsp.java:158)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:438)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:170)
org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:314)
org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1325)
org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1069)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1008)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:925)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:974)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:877)
javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:851)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
這是因為我在 JSP 中使用了 forEach 遍歷 user :
<c:forEach items="${user}" var="user">
<tr>
<th>${user.id}</th>
<th>${user.name}</th>
<th>${user.address}</th>
</tr>
</c:forEach>
但是我控制器返回的是單個物件,而針對單個物件無法使用 foreach 迭代,故報錯如上。
解決辦法是將應答的物件封裝到一個 list 中:List<User>
,然後再返回給檢視進行渲染解析。
相關推薦
javax.servlet.jsp.JspTagException: Don't know how to iterate over supplied "items" in xxx
今天使用SringMVC + Mybatis + JSP 搭建一個小 demo 的時候,報瞭如下錯誤 報錯資訊如下 type Exception report message An exception occurred processing JSP p
javax.servlet.jsp.JspTagException: Don't know how to iterate over supplied "items" in
十一月 20, 2018 11:02:42 下午 org.apache.catalina.core.ApplicationDispatcher invoke 嚴重: Servlet.service() for servlet jsp threw exception javax
Don't know how to iterate over supplied "items" in 問題的解決方法
曾經碰到如下錯誤: org.apache.jasper.JasperException: javax.servlet.ServletException: javax.servlet.jsp.JspTagException: Don't know how to itera
Don't know how to iterate over supplied "items" in 報錯解決
javax.servlet.jsp.JspTagException: Don't know how to iterate over supplied "items" in <forEach> at org.apache.taglibs.standard.
javax.servlet.ServletException: javax.servlet.jsp.JspTagException: Don't know how
在訪問某個頁面出現了上標題所示的異常。一開始我也不知道什麼原因,因為後臺已經返回了資料,而且前端的el/jstl表示式都寫的沒毛病。後來無意中想到,我這個資料是確定的只有一條,但是我還是用的<c:
javax.servlet.jsp.JspTagException: Don't know how to iterate over supplied "items" in <forEach>
十一月 20, 2018 11:02:42 下午 org.apache.catalina.core.ApplicationDispatcher invoke 嚴重: Servlet.service() for servlet jsp threw exception javax.servlet.jsp
Help! My company doesn't know how to use Git for production ready releases
My company is still widely using CVCS (Central Version Control Systems) tools mostly SVN. We've just now been slowly integrating Git into our department.Ou
jsp 頁面 javax.servlet.jsp.JspException cannot be resolved to a type 異常
not pro ima png post version 圖片 exce com <dependencies><dependency><groupId>javax.servlet</groupId><artifactId
javax.servlet.jsp.PageContext cannot be resolved to a type
not in cti 報錯 clas div stack contex question pen jsp項目中報錯: javax.servlet.jsp.PageContext cannot be resolved to a type stack overflow上找的解決
解決javax.servlet.jsp.JspException cannot be resolved to a type
pex jsp lib javax art jar let article 存在 java開發工具 在導入新項目後出現 javax.servlet.jsp.JspException cannot be resolved to a type錯誤信息: 解決方案: 看看項目
javax.servlet.jsp.JspException: Cannot retrieve mapping for action:xxxxxx
出現這個錯誤的原因是一個表單的action沒有與之對應的mapping相匹配,注意找找jsp和struts-config看每個細節是否寫錯 給出一個簡單的例子 hello.jsp頁面 <%@ page language="java" contentType="text/html;"
解決javax.servlet.jsp.JspException cannot be resolved to a type異常問題
使用eclipse-juno新建的maven專案,使用過程中無任何問題,但是換了eclipse-luna版本後,匯入同樣的maven專案,則報javax.servlet.jsp.JspException cannot be resolved to a type錯誤;這可能是新版本eclipse的bu
java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/core/Config
clas lang depend err tid con fig jsp version pom.xml中添加依賴即可 <dependency> <groupId>javax.servlet</groupId> <artif
eclipse,myeclipse匯入工程報:javax.servlet.jsp.JspException cannot be resolved to a type
今天從別的地方匯入工程的時候,發現匯入進來出現javax.servlet.jsp.JspException cannot be resolved to a type異常資訊,但是在工程匯出來的時候並沒有錯,原因是在工程中少了jsp-api.jar 包。 解決辦法:在工程中新增jsp-api.jar包,tom
java lang AbstractMethodError javax servlet jsp JspFactory
分享一下我老師大神的人工智慧教程!零基礎,通俗易懂!http://blog.csdn.net/jiangjunshow 也歡迎大家轉載本篇文章。分享知識,造福人民,實現我們中華民族偉大復興!  
I don't know what to say 事件的 NPM 包中獎名單,有你在用的嗎?
事件詳情請看 GitHub Issue 及 justjavac 釋出的文章 有人統計出目前引用了 event-stream 的 3900 多個包,如下: ps-tree nodemon flatmap-stream pstree.remy npm-run-all gulp-inject gulp-live
java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/core/Config 錯誤
出現這個錯誤主要是缺少jstl.jar包所導致的 解決方案如果是普通的web專案只需要新增上jar包即可 如果是maven專案 新增上一下依賴即可 <dependency> <groupId>javax.servlet</grou
java.lang.AbstractMethodError: javax.servlet.jsp.JspFactory.getJspApplicationContext(Ljavax/servlet/
我匯入雲筆記專案的時候,在專案啟動的時候,包了這個錯,我試著使用下面的方法能夠解決問題,而且可以正常啟動專案, 第一步刪除衝突的jar包 https://blog.csdn.net/testcs_dn/article/details/39582939 刪除這兩個jar包之後,還是
Springboot訪問jsp頁面報錯:javax.servlet.jsp.JspFactory.getJspApplicationContext
搭建springboot專案時,專案啟動成功,訪問jsp頁面跳轉時報錯,錯誤如下: java.lang.NoSuchMethodError: javax.servlet.jsp.JspFactory.getJspApplicationContext(Ljavax/servl
10 Useful Github Features You Probably Don’t Know
10 Useful Github Features You Probably Don’t Know https://medium.com/@aqeelakhtar.web/10-useful-github-features-you-probably-dont-know-c33352d0