下載本文檔
版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、劉曉濤,Spring組件裝配,集合裝配 自定義屬性編輯器(日期處理) 自動(dòng)裝配 抽象配置,本章目標(biāo),集合裝配,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類(lèi),覆蓋setAsText() 。 將屬性編輯器注冊(cè)到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(); ,自定義屬性編輯器-注冊(cè)到Spring, ,自動(dòng)裝配,byName:根據(jù)名字自動(dòng)裝配。 byType:根據(jù)類(lèi)型自動(dòng)裝配。 constructor:根據(jù)構(gòu)造器自動(dòng)裝配。 autodetect:自動(dòng)檢測(cè)自動(dòng)裝配方式。 no:不采取自動(dòng)裝配方式。 default:為no。 不是很贊同使用自動(dòng)裝配方式。,AutowireS
6、ervice類(lèi),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(); ,自動(dòng)裝配byName, - 效果一樣。,抽象配置,通過(guò)定義公共的屬性,指定abstract=true 具有相同屬性的類(lèi)在標(biāo)簽中指定其parent屬性 可以重用屬性配置。 ,Son類(lèi),public class Son private In
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 中醫(yī)藥宣傳資料制作指南
- 腦梗死急救護(hù)理流程標(biāo)準(zhǔn)
- 2026年智能電動(dòng)窗簾的電氣設(shè)計(jì)
- 市場(chǎng)調(diào)研報(bào)告寫(xiě)作技巧培訓(xùn)
- 企業(yè)外貿(mào)合同范本與注意事項(xiàng)
- 2026年歷史橋梁的耐久性及保護(hù)技術(shù)
- 酒店用品采購(gòu)與管理分類(lèi)標(biāo)準(zhǔn)
- 第十一課+創(chuàng)新思維要善于聯(lián)想+2026高考一輪復(fù)習(xí)
- 初中英語(yǔ)聽(tīng)力理解能力訓(xùn)練教程
- 企業(yè)員工激勵(lì)機(jī)制設(shè)計(jì)案例
- 2025版中國(guó)胃癌保功能手術(shù)外科專家共識(shí)課件
- TGXAS-火龍果品質(zhì)評(píng)價(jià)技術(shù)規(guī)范編制說(shuō)明
- (2025)70周歲以上老年人換長(zhǎng)久駕照三力測(cè)試題庫(kù)(含答案)3
- 口腔科門(mén)診主任年度工作匯報(bào)
- 福建省能源石化集團(tuán)有限責(zé)任公司2025年秋季招聘?jìng)淇碱}庫(kù)及一套完整答案詳解
- 2025年新聞?dòng)浾哔Y格證及新聞寫(xiě)作相關(guān)知識(shí)題庫(kù)附答案
- DB32∕T 5188-2025 經(jīng)成人中心靜脈通路裝置采血技術(shù)規(guī)范
- 深圳市2024-2025學(xué)年九年級(jí)上學(xué)期期末考試化學(xué)試卷(含答案)
- 中國(guó)傳統(tǒng)文化ppt
- 現(xiàn)代漢語(yǔ)語(yǔ)法研究-陸儉明
- 趙玉平管理領(lǐng)導(dǎo)學(xué)
評(píng)論
0/150
提交評(píng)論