给定的过滤条件是使用Java8中的流,如何在不使用流的情况下更改它。我必须从控制器的数据库中过滤客户和员工商品
else if
("Employee".equalsIgnoreCase(soption))
{ customerVOs = customerVOs.stream()
.filter( s-> s.getRole().equalsIgnoreCase("Employee"))
.collect(Collectors.toList());
}
model.addAttribute("customerVOs", customerVOs);发布于 2021-07-19 13:07:32
customerVOs = customerVOs.stream()
.filter( s-> s.getRole().equalsIgnoreCase("Employee"))
.collect(Collectors.toList());可以在没有流的情况下写入,如下所示,
for(var s: customerVOs){ // loop over your list from db
if(s.getRole().equalsIgnoreCase("Employee")){
// TODO add in list here
}
}https://stackoverflow.com/questions/68435182
复制相似问题