The fn:contains() function determines whether an input string contains a specified substring.


The fn:contains() function has following syntax:

boolean contains(java.lang.String, java.lang.String)


Following is the example to explain the functionality of this function:

<%@ taglib uri="" prefix="c" %>
<%@ taglib uri="" prefix="fn" %>
<title>Using JSTL Functions</title>

<c:set var="theString" value="I am a test String"/>

<c:if test="${fn:contains(theString, 'test')}">
   <p>Found test string<p>

<c:if test="${fn:contains(theString, 'TEST')}">
   <p>Found TEST string<p>


This would produce following result:

Found test string

source -

reference -

boolean contains(java.lang.String, java.lang.String)

첫번째 매개변수 타입으로 ArrayList도 가능

Posted by linuxism

댓글을 달아 주세요