ssh企业培训之spring组件装配

ssh企业培训之spring组件装配

ID:11530410

大小:1.87 MB

页数:15页

时间:2018-07-12

ssh企业培训之spring组件装配_第1页
ssh企业培训之spring组件装配_第2页
ssh企业培训之spring组件装配_第3页
ssh企业培训之spring组件装配_第4页
ssh企业培训之spring组件装配_第5页
资源描述:

《ssh企业培训之spring组件装配》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、刘晓涛Spring组件装配集合装配自定义属性编辑器(日期处理)自动装配抽象配置本章目标集合装配publicclassCollectionInjectionService{privateStringstrValue;privateintintValue;privateListlistValue;privateString[]arrayValue;privateSetsetValue;privateMapmapValue;privateDatedateValue;//getXxx()与setXxx()方法}集合装配

2、e="strValue"value="hellolxt008!!!">aaabbbxxxyyy数组与Li

3、st配置方式一样。集合装配abccbabacMainApplic

4、ationContextctx=newClassPathXmlApplicationContext("applicationContext.xml");CollectionInjectionServicecollectionInjectionService=(CollectionInjectionService)ctx.getBean("collectionInjectionService");System.out.println(collectionInjectionService.getStrValue());System.out

5、.println(collectionInjectionService.getIntValue());System.out.println(collectionInjectionService.getListValue());System.out.println(collectionInjectionService.getArrayValue()[2]);System.out.println(collectionInjectionService.getSetValue());System.out.println(collectionI

6、njectionService.getMapValue());自定义属性编辑器2009-03-25步骤:继承PropertyEditorSupport类,覆盖setAsText()。将属性编辑器注册到spring中。DateUtilPropertyEditorpublicclassDateUtilPropertyEditorextendsPropertyEditorSuppo

7、rt{privateStringformat="yyyy-MM-dd";publicvoidsetAsText(Stringtext) throwsIllegalArgumentException{SimpleDateFormatsdf=newSimpleDateFormat(format);try{Dated=sdf.parse(text);this.setValue(d);}catch(ParseExceptione){e.printStackTrace();}}}自定义属性编辑器-注册到Spring

8、

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。