ดังที่แสดงด้านล่าง:
@Override สตริงสาธารณะ getemployeebysup (String EmployeeId) {String str = ""; str = getemployeebysupselas (Employeeid, Str); return str.substring (0, str.lastindexof (",")); } @Override สตริงสาธารณะ getemployeebysupselas (String EmployeeId, String str) {str+= "'"+EmployeeId+"',"; System.out.println (str); String SQL = "เลือก U.EmployeeId จาก tbl_system_user u โดยที่ supervisorid = '"+EmployeeId+"'"; รายการ <string> list = jdbctemplate.QueryForList (SQL, String.class); if (list! = null && list.size ()> 0) {สำหรับ (int i = 0; i <list.size (); i ++) {str = getemployeebysupselas (list.get (i), str); }} return str; -ข้างต้นเป็นเนื้อหาเต็มรูปแบบของ Java Infinite Tree (Recursion) กรณีที่ใช้งานได้จริงที่นำมาให้คุณโดยบรรณาธิการ ฉันหวังว่าทุกคนจะสนับสนุน wulin.com เพิ่มเติม ~