




下載本文檔
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
1、劉曉濤,Spring組件裝配,集合裝配 自定義屬性編輯器(日期處理) 自動裝配 抽象配置,本章目標,集合裝配,public class CollectionInjectionService private String strValue; private int intValue; private List listValue; private String arrayValue; private Set setValue; private Map mapValue; private Date dateValue; /getXxx()與setXxx()方法 ,集合裝配, aaa bbb xxx
2、 yyy 數(shù)組與List配置方式一樣。,集合裝配, abc cba bac ,Main,ApplicationContext ctx=new ClassPathXmlApplicationContext(applicationContext.xml); CollectionInjectionService collectionInjectionService=(CollectionInjectionService)ctx.getBean(collectionInjectionService); System.out.println(collectionInjectionService.getS
3、trValue(); System.out.println(collectionInjectionService.getIntValue(); System.out.println(collectionInjectionService.getListValue(); System.out.println(collectionInjectionService.getArrayValue()2); System.out.println(collectionInjectionService.getSetValue(); System.out.println(collectionInjectionSe
4、rvice.getMapValue();,自定義屬性編輯器, 2009-03-25 步驟: 繼承PropertyEditorSupport類,覆蓋setAsText() 。 將屬性編輯器注冊到spring中。,DateUtilPropertyEditor,public class DateUtilPropertyEditor extends PropertyEditorSupport private String format=yyyy-MM-dd; public void setAsText(String text) throws IllegalArgumentException Simpl
5、eDateFormat sdf = new SimpleDateFormat(format); try Date d = sdf.parse(text); this.setValue(d); catch (ParseException e) e.printStackTrace(); ,自定義屬性編輯器-注冊到Spring, ,自動裝配,byName:根據(jù)名字自動裝配。 byType:根據(jù)類型自動裝配。 constructor:根據(jù)構(gòu)造器自動裝配。 autodetect:自動檢測自動裝配方式。 no:不采取自動裝配方式。 default:為no。 不是很贊同使用自動裝配方式。,AutowireS
6、ervice類,public class AutowireService CollectionInjectionService collectionInjectionService; public CollectionInjectionService getCollectionInjectionService() return collectionInjectionService; public void setCollectionInjectionService( CollectionInjectionService collectionInjectionService) this.collectionInjectionService = collectionInjectionService; public void call()System.out.println(collectionInjectionService.getListValue(); ,自動裝配byName, - 效果一樣。,抽象配置,通過定義公共的屬性,指定abstract=true 具有相同屬性的類在標簽中指定其parent屬性 可以重用屬性配置。 ,Son類,public class Son private In
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 股票知識入門培訓(xùn)
- 項羽之死說課課件
- 項目介紹框架課件模板
- 音樂鑒賞說課課件
- 音樂課件介紹
- 汽車配套產(chǎn)業(yè)基地項目人力資源管理方案(參考范文)
- 2025年貓爬架項目發(fā)展計劃
- 2025年組織毒活苗合作協(xié)議書
- 物業(yè)樓宇入伙流程
- 2025年多路信號老化檢測系統(tǒng)項目合作計劃書
- 氣管異物應(yīng)急預(yù)案
- 防臺風(fēng)防雷安全
- 服飾2個人合伙人協(xié)議書范文
- 高血壓病課件
- 生殖健康咨詢師復(fù)習(xí)題
- DB4116-T 058-2024 智慧消防物聯(lián)感知設(shè)備配置規(guī)范
- 2024年西藏自治區(qū)中考化學(xué)試題卷(含答案)
- 中間人介紹工作合同模板
- 第3章-機床夾具
- L07G324鋼筋混凝土密肋樓板
- 2024年軟件測試合同
評論
0/150
提交評論