没有合适的资源?快使用搜索试试~ 我知道了~
首页spring MVC数据绑定大全
spring MVC数据绑定 含例子 转载自疯芒毕露的专栏 刚开始用spring mvc 做web开发时 经常会不知道如何合适绑定页面数据 用惯struts2的朋友更认为spring mvc 绑定数据不如struts2方便 本人最开始也是这么认为 经过一段时间的应用和测试 总结出以下几种情况 希望对刚接触spring mvc 的朋友有所帮助 ">spring MVC数据绑定 含例子 转载自疯芒毕露的专栏 刚开始用spring mvc 做web开发时 经常会不知道如何合适绑定页面数据 用惯struts2的朋友更认为spring mvc 绑定数据不如struts2方便 本人最开始也是这么认为 经过一段时间的应用和测试 [更多]
资源详情
资源评论
资源推荐
Spring MVC
数据绑定大全
分类:Sun JAVA2010-10-07 21:246591 人阅读评论(2)收藏举报
springmvcclassinputuserstring
刚开始用 spring mvc 做 web 开发时,经常会不知道如何合适绑定页面数据.用惯 struts2 的朋
友更认为 spring mvc 绑定数据不如 struts2 方便(本人最开始也是这么认为),经过一段时间
的应用和测试,总结出以下几种情况,希望对刚接触 spring mvc 的朋友有所帮助.
示例程序下载
查看 spring 源码可以看出 spring 支持转换的数据类型已经很多了.
org.springframework.beans.PropertyEditorRegistrySupport.java
[java]view plaincopy
1. /**
2. *Actuallyregisterthedefaulteditorsforthisregistryinstanc
e.
3. */
4. privatevoiddoRegisterDefaultEditors(){
5. this.defaultEditors=newHashMap<Class,PropertyEditor>(64);
6. //Simpleeditors,withoutparameterizationcapabilities.
7. //TheJDKdoesnotcontainadefaulteditorforanyofthese
targettypes.
8. this.defaultEditors.put(Charset.class,newCharsetEditor());
9. this.defaultEditors.put(Class.class,newClassEditor());
10. this.defaultEditors.put(Class[].class,newClassArrayEditor())
;
11. this.defaultEditors.put(Currency.class,newCurrencyEditor());
12. this.defaultEditors.put(File.class,newFileEditor());
13. this.defaultEditors.put(InputStream.class,newInputStreamEdit
or());
14. this.defaultEditors.put(Locale.class,newLocaleEditor());
15. this.defaultEditors.put(Pattern.class,newPatternEditor());
16. this.defaultEditors.put(Properties.class,newPropertiesEditor
());
17. this.defaultEditors.put(Resource[].class,newResourceArrayPro
pertyEditor());
18. this.defaultEditors.put(TimeZone.class,newTimeZoneEditor());
19. this.defaultEditors.put(URI.class,newURIEditor());
20. this.defaultEditors.put(URL.class,newURLEditor());
21. //Defaultinstancesofcollectioneditors.
22. //Canbeoverriddenbyregisteringcustominstancesofthose
ascustomeditors.
23. this.defaultEditors.put(Collection.class,newCustomCollection
Editor(Collection.class));
24. this.defaultEditors.put(Set.class,newCustomCollectionEditor(
Set.class));
25. this.defaultEditors.put(SortedSet.class,newCustomCollectionE
ditor(SortedSet.class));
26. this.defaultEditors.put(List.class,newCustomCollectionEditor
(List.class));
27. this.defaultEditors.put(SortedMap.class,newCustomMapEditor(S
ortedMap.class));
28. //Defaulteditorsforprimitivearrays.
29. this.defaultEditors.put(byte[].class,newByteArrayPropertyEdi
tor());
30. this.defaultEditors.put(char[].class,newCharArrayPropertyEdi
tor());
31. //TheJDKdoesnotcontainadefaulteditorforchar!
32. this.defaultEditors.put(char.class,newCharacterEditor(false)
);
33. this.defaultEditors.put(Character.class,newCharacterEditor(t
rue));
34. //Spring'sCustomBooleanEditoracceptsmoreflagvaluesthan
theJDK'sdefaulteditor.
35. this.defaultEditors.put(boolean.class,newCustomBooleanEditor
(false));
36. this.defaultEditors.put(Boolean.class,newCustomBooleanEditor
(true));
37. //TheJDKdoesnotcontaindefaulteditorsfornumberwrapper
types!
38. //OverrideJDKprimitivenumbereditorswithourownCustomNu
mberEditor.
39. this.defaultEditors.put(byte.class,newCustomNumberEditor(Byt
e.class,false));
40. this.defaultEditors.put(Byte.class,newCustomNumberEditor(Byt
e.class,true));
41. this.defaultEditors.put(short.class,newCustomNumberEditor(Sh
ort.class,false));
42. this.defaultEditors.put(Short.class,newCustomNumberEditor(Sh
ort.class,true));
43. this.defaultEditors.put(int.class,newCustomNumberEditor(Inte
ger.class,false));
44. this.defaultEditors.put(Integer.class,newCustomNumberEditor(
Integer.class,true));
45. this.defaultEditors.put(long.class,newCustomNumberEditor(Lon
g.class,false));
46. this.defaultEditors.put(Long.class,newCustomNumberEditor(Lon
g.class,true));
47. this.defaultEditors.put(float.class,newCustomNumberEditor(Fl
oat.class,false));
48. this.defaultEditors.put(Float.class,newCustomNumberEditor(Fl
oat.class,true));
49. this.defaultEditors.put(double.class,newCustomNumberEditor(D
ouble.class,false));
50. this.defaultEditors.put(Double.class,newCustomNumberEditor(D
ouble.class,true));
51. this.defaultEditors.put(BigDecimal.class,newCustomNumberEdit
or(BigDecimal.class,true));
52. this.defaultEditors.put(BigInteger.class,newCustomNumberEdit
or(BigInteger.class,true));
53. //Onlyregisterconfigvalueeditorsifexplicitlyrequested.
54. if(this.configValueEditorsActive){
55. StringArrayPropertyEditorsae=newStringArrayPropertyEdi
tor();
56. this.defaultEditors.put(String[].class,sae);
57. this.defaultEditors.put(short[].class,sae);
58. this.defaultEditors.put(int[].class,sae);
59. this.defaultEditors.put(long[].class,sae);
60. }
61. }
1.基本数据类型
很简单,该怎么写就怎么写.
剩余13页未读,继续阅读
野孩子1969
- 粉丝: 0
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 收起
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
会员权益专享
最新资源
- ExcelVBA中的Range和Cells用法说明.pdf
- 基于单片机的电梯控制模型设计.doc
- 主成分分析和因子分析.pptx
- 共享笔记服务系统论文.doc
- 基于数据治理体系的数据中台实践分享.pptx
- 变压器的铭牌和额定值.pptx
- 计算机网络课程设计报告--用winsock设计Ping应用程序.doc
- 高电压技术课件:第03章 液体和固体介质的电气特性.pdf
- Oracle商务智能精华介绍.pptx
- 基于单片机的输液滴速控制系统设计文档.doc
- dw考试题 5套.pdf
- 学生档案管理系统详细设计说明书.doc
- 操作系统PPT课件.pptx
- 智慧路边停车管理系统方案.pptx
- 【企业内控系列】企业内部控制之人力资源管理控制(17页).doc
- 温度传感器分类与特点.pptx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论1