http://localhost:8080/Cookie/el2.jsp?name=A&name=b
<br>${ paramValues.name[0].class} 得不到類型
視頻裡就是這樣用的,我怎麼運行就報錯了呢?
type Exception report
message An exception occurred processing JSP page /el2.jsp at line 33
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 /el2.jsp at line 33
30: <%
31: String str = "123";
32: %>
33: <br>${paramValues.name[0].class}
34: </body>
35:
36: </html>
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:574)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:476)
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)
在tomcat 7及以上版本 中默認會檢查EL表達式中是否會有java關鍵字。
names: ${paramValues.name[0].class } //這樣就是會報錯
names: ${paramValues.name[0]["class"] } //這樣就不會報錯了
再如Session#isNew() ,要${pageContext.session['new']}這樣表達。