我在应用程序上下文中有一个对象列表,我希望筛选这个列表,以获得一个显示jsp页面的元素。我尝试使用流过滤函数过滤列表:
<c:set var="itemDetalias" value="${applicationScope.productList.stream().filter(p -> p.getId() == item.getProductId()).collect(java.util.stream.Collectors.toList()).get(0)}" />但是我有一个错误消息:
${applicationScope.productList.stream().filter( ppp -> ppp.getId() == item.getProductId()).collect(java.util.stream.Collectors.toList()).get(0)}'
Method not found: class org.apache.el.stream.Stream.collect(null)
我如何过滤列表?
发布于 2017-03-21 14:55:29
我找到了解决办法。Tomcat有它的自己的流库,它有一些像filter这样的函数,但是它没有collect函数。而不是使用collect函数,而是使用toList函数。
新的项目应是:
<c:set var="itemDetalias" value="${applicationScope.productList.stream().filter(p -> p.getId() == item.getProductId()).toList().get(0)}" />https://stackoverflow.com/questions/42886987
复制相似问题