1

Is there is any way to check if expected element is present in array in EL? I don't see any other way other than iterate the whole array and see if value matches the expected one.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Dhakchianandan
  • 351
  • 1
  • 6
  • 15

1 Answers1

1

If you are using Spring Framework, you can use Spring TagLib + SpEL and common-lang3:

<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
---
<spring:eval var="containsValue" expression="T(org.apache.commons.lang3.ArrayUtils).contains(yourArray, 'expectedElement')" />
Contains (true or false): ${containsValue}
xxg
  • 2,048
  • 1
  • 11
  • 14