Is it possible to you use something from database in a class tag in JSP?

时间:2019-05-31 11:32:42

标签: java spring-boot jsp taglib

Im trying to get something out of my database to add to a class in my JSP.

<div class="selection <c:out value='${bill.category}'/>">

<c:forEach items="${bills}" var="bill">
        <div class="selection <c:out value='${bill.category}'/>">
            <p><c:out value="${bill.name}"/></p>
            <div class="plus-icon">
                <ion-icon size="large" name="add-circle-outline</ion-icon
            </div>
        </div>
    </c:forEach>

1 个答案:

答案 0 :(得分:0)

是的,您可以使用jstl标签,如下所示:

<c:set var="category" value="${bill.category}"/>

然后像下面这样在div中使用上面的内容:

   <!--will print whatever is there in category-->
    <div class="selection${category}">
    </div>