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
报错类似题目这样的是因为你相应的类没有序列化,只需要在相关类后继承序列化接口即可。
1164 0
报错ERROR 3576 --- [nio-8080-exec-4] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for
|
2月前
|
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
|
4月前
spring3 springfox报错Type javax.servlet.http.HttpServletRequest not present
spring3 springfox报错Type javax.servlet.http.HttpServletRequest not present
138 0
|
4月前
|
缓存 Java Spring
servlet/filter/listener/interceptor区别与联系
servlet/filter/listener/interceptor区别与联系
58 0
|
Java
ApplicationContext is unlikely to start due to a @ComponentScan of the default package
解决办法: 1、一般发出这个警告的原因是你把启动类直接放在的src目录下面。 2、你需要在src目录下面再建一个包,然后把启动类放到下面。 3、或者你错将启动类放到java文件中了,与项目包成了同级文件,你只需要将启动类放到项目包里就可以。
74 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 应用服务中间件
严重: 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.
262 0
严重: Exception sending context destroyed event to listener instance of class org.springframework.web.
|
JSON Dubbo Java
Failed to meta-introspect annotation interface org.springframework.web.bind.annotation.RequestBody:
Failed to meta-introspect annotation interface org.springframework.web.bind.annotation.RequestBody:
252 0
Failed to meta-introspect annotation interface org.springframework.web.bind.annotation.RequestBody: