First, Vue.js cycle
Vue.js Loop to use the V-FOR directive.
The V-FOR directive needs to be used in a special syntax in the form of student in Studentlist , where studentlist is the source data array and student is an alias for the iteration of the array element.
<id= "MyDiv1"> <ol> < v-for= "Student in Studentlist">{{student.name}}</ Li > </ ol > </ Div >
<Scripttype= "Text/javascript"> varstudentlist=[{name:'Small One'},{name:'Little Two'},{name:'Small Three'}]; varMyviewmodel= NewVue ({el:'#MyDiv1', Data:{studentlist}});</Script>
The effect is as follows:
Second, the Java loop
1) Create a class
Package Entity;public class Student { private String name; public void SetName (String name) { this.name = name; } Public String GetName () { return name; } }
2) Create a Main method
Package Entity;import Java.util.arraylist;import Java.util.list;public class Main {public static void main (string[ ] args) {Student S1 = new Student (); New Out object Student s2 = new Student (); Student s3 = new Student (); S1.setname ("small One"); Set the value of the property to S2.setname ("small Two"); S3.setname ("small Three"); List<Student>Studentlist = new ArrayList<Student>(); Studentlist.add (S1);//Add the attribute value to the collection studentlist.add (S2); Studentlist.add (S3); for (Student s:studentlist) {//Loop traversal out System.out.println (S.getname ()); } Student s4 = new Student (); S4.setname ("small Four"); Studentlist.add (S4); When adding data, the data is added in order, because the data is out of sync, so adding extra time data is not added}}
The effect is as follows:
Three, jstl Tag library
<Body> <%List<String>List= NewArrayList<String>(); List.add ("Study hard 1"); List.add ("Study Hard 2"); List.add ("Study Hard 3"); Request.setattribute ("List", list); %> <b>Iterate through all the elements of the list collection:</b> <BR> <C:foreachItems= "${requestscope.list}"var= "keyword"Varstatus= "id">${id.index} ${keyword}<BR> </C:foreach> <b>Iterates over the element after the first element in the list collection (excluding the first element):</b> <BR>
Part of the Loop<C:foreachItems= "${requestscope.list}"var= "keyword"Varstatus= "id"begin= "1">${id.index} ${keyword}<BR> </C:foreach> </Body>
Iv. Database Cycle
CURSOR Mycur is SELECT name FORM t_student; BEGIN -Opens open mycur; LOOP FETCH mycur into V_name; Exit exit when no data is Mycur%notfound; --print display; END LOOP; END;
vue.js--Loop (Java, jstl tag Library, database)