Reputation: 8322
I am using JSP EL. I have a string like "Village Green,Colgate University,Hamilton,NY"
. I want to show only Village Green
. How can I do this?
<c:forEach items="${listOfSources}" var = "source">
<option value="${source }" >${source }</option>
</c:forEach>
The option value should be the whole string, but I want to show only Village Green
to select. How can I achieve this?
Upvotes: 0
Views: 4130
Reputation: 240946
Use just substringBefore
from JSTL
assuming that you need String
from0 to first ,
Code Snippet:
<c:out value="${fn:substringBefore(source,',')}"/>
Document :
Upvotes: 2