JSTL---Servlet.service() for servlet action threw exceptionjavax.el.MethodNotFoundException Method s

简介:

JSTL---Servlet.service() for servlet action threw exceptionjavax.el.MethodNotFoundException Method size

 

         背景

         最近在项目测试的时候,发现有的JSP页面有时会出现如下错误:

JSTL--- Servlet.service() for servlet action threw exceptionjavax.el.MethodNotFoundExceptionMethod size

 

         原因

         EL表达式语法错误,页面中绑定数据使用的是JSTL,所以有时会出现判空的情况写法如下:

<c:if test = “${list.size>0}”>
……
</c:if>

         而EL表达式并不支持${list.size>0}这种写法。

 

         解决方法

         其实,JSTL是有相关的函数支持获取集合的大小大。我们需要再引入一个标签

<%@taglib uri="http://java.sun.com/jsp/jstl/core"prefix="c"%> 
<%@taglib prefix="fn"uri="http://java.sun.com/jsp/jstl/functions"%> 

         EL表达式的正确写法

<c:if test = “${fn:length(list)}”>
……
</c:if>

        

         更多的知识大家可以去下面的链接地址看看:

         JSTL官网:https://jstl.java.net/

         开源中国JSTL社区:http://www.oschina.net/question/tag/jstl

         JSTL标签库:http://www.runoob.com/jsp/jsp-jstl.html


目录
相关文章
报错ERROR 3576 --- [nio-8080-exec-4] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for
报错类似题目这样的是因为你相应的类没有序列化,只需要在相关类后继承序列化接口即可。
1228 0
报错ERROR 3576 --- [nio-8080-exec-4] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for
|
4月前
|
Java
Servlet.service() for servlet [dispatcherServlet] in contextIllegal base64 character 3a,好建议,建一个bug方
Servlet.service() for servlet [dispatcherServlet] in contextIllegal base64 character 3a,好建议,建一个bug方
Servlet.service() for servlet [dispatcherServlet] in contextIllegal base64 character 3a,好建议,建一个bug方
|
Java 数据库连接 mybatis
Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception
在进行springboot和mybatis遇到了这个错误 Servlet.service() for servlet [dispatcherServlet] in context with path [] th
Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception
|
6月前
spring3 springfox报错Type javax.servlet.http.HttpServletRequest not present
spring3 springfox报错Type javax.servlet.http.HttpServletRequest not present
226 0
|
6月前
Servlet3.0+环境下使用注解注册Servlet、Filter和Listener组件
Servlet3.0+环境下使用注解注册Servlet、Filter和Listener组件
72 2
|
6月前
|
缓存 Java Spring
servlet/filter/listener/interceptor区别与联系
servlet/filter/listener/interceptor区别与联系
71 0
|
Java Spring
required a bean of type ‘org.springframework.web.client.RestTemplate‘ that could not be found.
required a bean of type ‘org.springframework.web.client.RestTemplate‘ that could not be found.
required a bean of type ‘org.springframework.web.client.RestTemplate‘ that could not be found.
|
前端开发 Java 应用服务中间件
Error configuring application listener of class org.springframework.web.context.ContextLoader
Error configuring application listener of class org.springframework.web.context.ContextLoader
Error configuring application listener of class org.springframework.web.context.ContextLoader
|
Java 应用服务中间件 Maven
Error configuring application listener of class org.springframework.web.context.ContextLoaderListene
Error configuring application listener of class org.springframework.web.context.ContextLoaderListene
111 0
|
Java 应用服务中间件
严重: Exception sending context destroyed event to listener instance of class org.springframework.web.
严重: Exception sending context destroyed event to listener instance of class org.springframework.web.
291 0
严重: Exception sending context destroyed event to listener instance of class org.springframework.web.