下面要跟大家介紹下mybatis結果產生鍵值對的實例程式碼,具體內容如下所示:
在實際應用程式中我們常常會遇到這樣的情況,需要給下拉框賦值,這個時候就需要鍵值對了,具體使用方法如下
1,在maper.xml檔中定義結果型別(resultType)定義為hashmap,如下所示
#<select id="selectSuperUnitInfo" resultType="hashmap"> SELECT unit_id ,unit_name from unit_info </select>
2,在對應的mapper類別中用List
public List<Map<String,String>> selectSuperUnitInfo();
其實最強大的莫過於resultMap類型了,這個可以在mapper.xml檔案中自訂擴充類型,然後在套件中加入這個類型即可,真是強大
下面給大家補充下MyBatis回傳Map鍵值對資料
##
List<Map<String, String>> getMtypeList(); <select id="getMtypeList" resultType="java.util.HashMap"> select code,`name` from jk_control_measure </select>
[DEBUG] 2016-08-29 17:50:09 :==> Executing: select code,`name` from jk_control_measure [DEBUG] 2016-08-29 17:50:09 :==> Parameters: [DEBUG] 2016-08-29 17:50:10 :<== Columns: code, name [DEBUG] 2016-08-29 17:50:10 :<== Row: one, 地面冲洗 [DEBUG] 2016-08-29 17:50:10 :<== Row: two, 边界围挡 [DEBUG] 2016-08-29 17:50:10 :<== Row: three, 垃圾覆盖 [DEBUG] 2016-08-29 17:50:10 :<== Row: four, 裸地覆盖 [DEBUG] 2016-08-29 17:50:10 :<== Row: five, 洒水降尘 [DEBUG] 2016-08-29 17:50:10 :<== Row: six, 车辆冲洗 [DEBUG] 2016-08-29 17:50:10 :<== Row: seven, 建筑渣土 [DEBUG] 2016-08-29 17:50:10 :<== Row: eight, 车辆冒装 [DEBUG] 2016-08-29 17:50:10 :<== Row: nine, 扬尘覆盖 [DEBUG] 2016-08-29 17:50:10 :<== Row: ten, 车辆撒漏 [DEBUG] 2016-08-29 17:50:10 :<== Row: eleven, 车辆黑烟 [DEBUG] 2016-08-29 17:50:10 :<== Row: twelve, 道路积尘
[{"NAME":"地面冲洗","name":"地面冲洗","code":"one","CODE":"one"}, {"NAME":"边界围挡","name":"边界围挡","code":"two","CODE":"two"}, {"NAME":"垃圾覆盖","name":"垃圾覆盖","code":"three","CODE":"three"}, {"NAME":"裸地覆盖","name":"裸地覆盖","code":"four","CODE":"four"}, {"NAME":"洒水降尘","name":"洒水降尘","code":"five","CODE":"five"}, {"NAME":"车辆冲洗","name":"车辆冲洗","code":"six","CODE":"six"}, {"NAME":"建筑渣土","name":"建筑渣土","code":"seven","CODE":"seven"}, {"NAME":"车辆冒装","name":"车辆冒装","code":"eight","CODE":"eight"}, {"NAME":"扬尘覆盖","name":"扬尘覆盖","code":"nine","CODE":"nine"}, {"NAME":"车辆撒漏","name":"车辆撒漏","code":"ten","CODE":"ten"}, {"NAME":"车辆黑烟","name":"车辆黑烟","code":"eleven","CODE":"eleven"}, {"NAME":"道路积尘","name":"道路积尘","code":"twelve","CODE":"twelve"} ]#傳回的結果帶有大寫與小寫的key如果在sql語句中的列名使用大寫會怎麼樣呢?自己測試一下吧!如果大家有任何疑問請給我留言,小編會及時回覆大家的。在此也非常感謝大家對PHP中文網的支持! 更多Mybatis結果產生鍵值對相關文章請關注PHP中文網!

JavaachievesPlatFormIndependencethroughTheJavavIrtualMachine(JVM),允許Codetorunondifferentoperatingsystemsswithoutmodification.thejvmcompilesjavacodeintoplatform-interploplatform-interpectentbybyteentbytybyteentbybytecode,whatittheninternterninterpretsandectectececutesoneonthepecificos,atrafficteyos,Afferctinginginginginginginginginginginginginginginginginginginginginginginginginginginginginginginginginginginginginginginginginginginging

JavaispoperfulduetoitsplatFormitiondence,對象與偏見,RichstandardLibrary,PerformanceCapabilities和StrongsecurityFeatures.1)Platform-dimplighandependectionceallowsenceallowsenceallowsenceallowsencationSapplicationStornanyDevicesupportingJava.2)

Java的頂級功能包括:1)面向對象編程,支持多態性,提升代碼的靈活性和可維護性;2)異常處理機制,通過try-catch-finally塊提高代碼的魯棒性;3)垃圾回收,簡化內存管理;4)泛型,增強類型安全性;5)ambda表達式和函數式編程,使代碼更簡潔和表達性強;6)豐富的標準庫,提供優化過的數據結構和算法。

javaisnotirelyplatemententedduetojvmvariationsandnativecodinteinteration,butitlargelyupholdsitsitsworapromise.1)javacompilestobytecoderunbythejvm

thejavavirtualmachine(JVM)IsanabtractComputingmachinecrucialforjavaexecutionasitrunsjavabytecode,使“ writeononce,runanywhere”能力

Javaremainsagoodlanguageduetoitscontinuousevolutionandrobustecosystem.1)Lambdaexpressionsenhancecodereadabilityandenablefunctionalprogramming.2)Streamsallowforefficientdataprocessing,particularlywithlargedatasets.3)ThemodularsystemintroducedinJava9im

Javaisgreatduetoitsplatformindependence,robustOOPsupport,extensivelibraries,andstrongcommunity.1)PlatformindependenceviaJVMallowscodetorunonvariousplatforms.2)OOPfeatureslikeencapsulation,inheritance,andpolymorphismenablemodularandscalablecode.3)Rich

Java的五大特色是多態性、Lambda表達式、StreamsAPI、泛型和異常處理。 1.多態性讓不同類的對象可以作為共同基類的對象使用。 2.Lambda表達式使代碼更簡潔,特別適合處理集合和流。 3.StreamsAPI高效處理大數據集,支持聲明式操作。 4.泛型提供類型安全和重用性,編譯時捕獲類型錯誤。 5.異常處理幫助優雅處理錯誤,編寫可靠軟件。


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

EditPlus 中文破解版
體積小,語法高亮,不支援程式碼提示功能

PhpStorm Mac 版本
最新(2018.2.1 )專業的PHP整合開發工具

SublimeText3 Linux新版
SublimeText3 Linux最新版

WebStorm Mac版
好用的JavaScript開發工具

ZendStudio 13.5.1 Mac
強大的PHP整合開發環境