0
美好的一天,我試圖將所有用戶從我的數據庫添加到列表中並將其打印出來。但問題是我只檢索用戶表的最後記錄。其他人被忽略。這裏是我的代碼sql.eachRow只會將最後一條記錄添加到列表中
table(selectionMode: ListSelectionModel.SINGLE_SELECTION){
sql.eachRow("select * from users"){row->
println row;
def staffList = []
staffList.add(uname:row.uname,pwd:row.pwd);
tableModel(list : staffList){
closureColumn(header:'Username',read:{row1 -> return row1.uname})
closureColumn(header:'Password',read:{row1 -> return row1.pwd})
}
你好,@Steve Lovell!非常感謝!它確實有效。所以每個閉包都是一個循環。我很抱歉,因爲我在Groovy是一個新手。非常感謝! – IWantToBeAnAnonymous
太好了。如果你可以將其標記爲答案,那將是可愛的。 –