单元测试和导入context的一些技巧 ..................................................................................... 75
国际化和MessageSource ...................................................................................................... 76
事件的发布和订阅 ............................................................................................................ 77
深入探讨MyUsers的ApplicationContext.xml ............................................................................ 77
本章小结 ................................................................................................................................. 78
4. Spring MVC 框架 ............................................................................................................................ 79
概述 ........................................................................................................................................ 79
Spring Controller单元测试 ........................................................................................................... 81
配置DispatcherServlet和ContextLoaderListener ................................................................................ 81
修改web.xml,使用Spring的DispatchServlet ........................................................................... 82
为UserController编写单元测试 ............................................................................................ 84
创建UserController,配置action-servlet.xml ............................................................................ 85
创建userList.jsp页面显示用户列表 ....................................................................................... 87
为UserFormController创建单元测试 ..................................................................................... 90
创建UserFormController,并在action-servlet.xml中配置它 ....................................................... 92
创建userForm.jsp页面,以便编辑用户资料 .......................................................................... 97
为Spring配置Commons Validator .......................................................................................... 99
SimpleFormController:方法生命周期回顾 .................................................................................. 102
Spring的JSP标签 ...................................................................................................................... 104
本章小结 ................................................................................................................................ 105
5. 高级的MVC框架----使用模板,验证,异常处理,文件上传 ............................................................. 106
SiteMesh模板技术 .................................................................................................................... 106
安装和配置 .................................................................................................................... 107
Tiles模板技术 .......................................................................................................................... 111
安装和配置 .................................................................................................................... 111
Spring验证方法 ....................................................................................................................... 117
使用Commons Validator ............................................................................................................ 119
XDoclet .......................................................................................................................... 120
一系列的验证器 .............................................................................................................. 121
在业务委派中进行验证 .................................................................................................... 121
Spring未来的声明式验证框架 ........................................................................................... 122
控制器中的异常处理 ............................................................................................................... 123
上传文件 ................................................................................................................................ 126
拦截请求 ................................................................................................................................ 131
发送邮件 ................................................................................................................................ 133
本章小结 ................................................................................................................................ 135
6. View的多种选择 ........................................................................................................................... 136
View(视图)和ViewResolver(视图解析器) ...................................................................................... 136
利用jWebUnit测试View ............................................................................................................. 138
JSP ......................................................................................................................................... 140
View Resolver配置 ............................................................................................................ 140
JSTL .............................................................................................................................. 142
Tiles ............................................................................................................................... 143
Velocity ................................................................................................................................... 144
在MyUsers中使用Velocity .................................................................................................. 144
SiteMesh和Velocity ............................................................................................................ 146
创建Velocity模板 ............................................................................................................. 148
部署和测试 .................................................................................................................... 150
Velocity小结 .................................................................................................................... 151
FreeMarker .............................................................................................................................. 151
View Resolver配置 ............................................................................................................ 151
SiteMesh和FreeMarker ....................................................................................................... 152
创建FreeMarker模板 ......................................................................................................... 155
部署和测试 .................................................................................................................... 158
v
Spring live中文版
XML to PDF by RenderX XEP XSL-FO Formatter, visit us at http://www.renderx.com/