前提:在页面上面引入EL表达式的类库
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
1、String str = "month_id1,String1,账期1,2017101";
切割字符串,并遍历
//非空判断
<c:if test="${not empty str }">
//切割字符串
<c:set value="${ fn:split(str, ',') }" var="strList" />
//遍历
<c:forEach items="${strList}" var="strname" varStatus="i">
//EL表达式中的if else
<c:choose>
//如果
<c:when test="${i.index == 3}">
${strname}
</c:when>
//否则
<c:otherwise>
${strname}+否则
</c:otherwise>
</c:choose>
</c:forEach>
</c:if>
结果:month_id1 String1 账期1 2017101
版权声明:本文为yapengliu原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。