我需要在JSTL代码中创建HTML项目符号点文本,如
段落文字
我正在使用代码
<div>
<p>${otherTest}</p>
<c:forEach items="${result}" var="currentItem" varStatus="stat">
Tips ${stat.index +1 }: ${currentItem}<br>
</c:forEach>
</div>
此处结果包含paragrapth文本和示例文本。我怎么能做到这一点?
答案 0 :(得分:1)
使用此
<c:set var="data"
value="this is title text\n this is the headigs text: \n
this is the tip tesxt1 \n this is the tip text2\nthis is the tip text3"></c:set>
<c:set var="newline" value="\n" />
<c:set var="dtatPart" value="${fn:split(data, newline)}"></c:set>
<c:set var="limit" value="${fn:length(fn:split(data, newline))}"></c:set>
<p>
<i>Tip: ${dtatPart[0]}</i>
</p>
<br>
${dtatPart[1]}
<ul>
<c:forEach var="i" begin="2" end="${limit-1}">
<li>${dtatPart[i]}</li>
</c:forEach>
</ul>