列表匯出 普通方法

2021-09-19 12:23:45 字數 1338 閱讀 4563

以學生表student(id,name,age,telephone,teacher_id,remark)與教師表teacher(id,name,class_name,telephone)為例

選擇要匯出的行資料,ids為選擇的行id。

1.controller層 

/**

* 匯出學生列表excel

*/public void studentexcel(string ids)

2.service層

/**

* 獲取匯出列

*/listgetalllist(string ids);

/*** 匯出excel

*/void toexcel(httpservletresponse response, string path, listlist);

3.serviceimp實現層

/**

* 獲取匯出列

*/@override

public listgetalllist(string ids) );

return list;

}/**

* 匯出excel

mapfields.put("name", "學生名稱");

mapfields.put("age", "年齡");

mapfields.put("telephone", "聯絡**");

mapfields.put("remark", "備註");

deriveexcel.exportexcel(sheetname, list, mapfields, response, path);

} catch (exception e)

}

4.studentdao層

/**

* 獲取匯出列

**/listgetalllist(listids);

5.xml層

select id,name,age,telephone,remark,teacher_id

from student where 1=1

0">

and id in

#

列表解析和普通的列表建立方法時間優化對比

測試背景 建立兩個列表,裡面的元素全為0,即 0,0 方法一 列表解析 blocks img 0 for i in range 1000 for i in range 1000 方法二 普通的列表建立 blocks img for i in range 1000 for i in range 100...

普通方法引用

public class main thread thread newthread runnable thread.start 需要使用函式式介面的物件的地方可以使用lambda表示式 public static void main string args 2.thread thread newth...

普通LIST列表轉換為Tree

public class xmgltaskdto 重新將list轉為tree 方式1 迴圈 listnodelist new arraylist for xmgltaskdto node1 taskdtolist if mark 重新將list轉為tree 方式2 遞迴 listnodelist n...