Two methods:
For example, there are drop-down boxes
<select></select> where the options need to be displayed cyclically
1.JAVA Code Loop
<%
for (int i=0;i<list.size (); i++) {
Vo = List.get (i);
%>
<option value= "<%=vo.id%>" <%if (id==vo.id) {out.print ("selected")}%>><%=vo.id%></ Option>
<%
}
%>
2.JSTL Cycle
First, you need to introduce the JSTL source file in the JSP file: <% @taglib prefix= "C" uri= "Http://java.sun.com/jsp/jstl/core"%>
<c:if test= "${empty list}" >
Where the status of Varstatus= "status" equals I, is the index value
<c:foreach item= "${list}" vars= "Vo" varstatus= "status" >
where if the vo.id== "0", equals the value can be a JS variable, not a Java variable
<option value= "${vo.id}" <c:if test= "${vo.id=" 0 "}" >selected</c:if>>${vo.name}</option>
</c:foreach>
</c:if>
As in Method 2, if the vo.id== "0" in the judgment, the value is equal to the Java variable, so it is using method one
JSP Loop Cache List