没有合适的资源?快使用搜索试试~ 我知道了~
首页Spring框架3.1开发完全指南
"Spring3.1开发宝典.pdf"
Spring框架是Java开发中广泛使用的轻量级框架,Spring3.1版本在当时引入了许多新的特性和改进。这份文档详细阐述了Spring框架的核心概念、模块组成以及如何在实际项目中使用。
1. **Spring框架概述**
Spring是一个开源的应用框架,它提供了全面的基础设施支持,帮助开发者创建企业级的Java应用。它强调代码的可测试性和基于POJO(Plain Old Java Object)的编程模型,降低了Java EE平台的复杂性。
2. **依赖注入与控制反转(DI/IoC)**
Spring的核心特性之一就是依赖注入(Dependency Injection,简称DI),也称为控制反转(Inversion of Control,简称IoC)。通过这个机制,Spring可以管理对象的生命周期和对象之间的依赖关系,使得代码更加松耦合,易于测试和维护。
3. **Spring模块**
- **核心容器**(Core Container):包括Bean工厂和应用上下文,负责管理对象的生命周期和装配。
- **数据访问/集成**(Data Access/Integration):支持JDBC、ORM(Object-Relational Mapping)如Hibernate和MyBatis,以及OXM(Object-XML Mapping)等。
- **Web**:提供了与Web相关的功能,如Servlet、Struts和Portlet的集成。
- **面向切面编程与Instrumentation**(AOP and Instrumentation):支持面向切面编程,用于编写可重用的代码,如日志、事务管理等。
- **测试**(Test):提供测试支持,包括单元测试和集成测试。
4. **使用场景**
Spring适用于各种应用场景,包括但不限于:企业级服务、Web应用、轻量级应用服务器、数据访问、事务管理、安全控制等。
5. **依赖管理和命名规范**
Spring框架提供了一套依赖管理规则,以确保组件间的兼容性。文档详细介绍了如何使用Maven和Ivy进行依赖管理,并讲解了Spring自身的依赖和依赖于Spring的项目应该如何配置。
6. **日志**
Spring框架支持多种日志系统,如Log4j、Java Util Logging、Commons Logging等,允许开发者灵活选择日志实现。
这份PDF文档作为Spring3.1的参考文档,是开发者理解和学习Spring框架的重要资料,它详细解释了Spring的各种特性和使用方法,对于初学者和有经验的开发者都是极好的参考资料。
16.11. Handling exceptions ...................................................................................477
HandlerExceptionResolver ............................................................................477
@ExceptionHandler ......................................................................................478
16.12. Convention over configuration support ........................................................478
The Controller ControllerClassNameHandlerMapping ....................................479
The Model ModelMap (ModelAndView) .......................................................480
The View - RequestToViewNameTranslator ..................................................481
16.13. ETag support ..............................................................................................483
16.14. Configuring Spring MVC ............................................................................483
Enabling MVC Java Config or the MVC XML Namespace .............................484
Customizing the Provided Configuration ........................................................485
Configuring Interceptors ...............................................................................486
Configuring View Controllers .......................................................................486
Configuring Serving of Resources .................................................................487
mvc:default-servlet-handler ...........................................................................489
More Spring Web MVC Resources ................................................................490
Advanced Customizations with MVC Java Config ..........................................490
Advanced Customizations with the MVC Namespace .....................................491
17. View technologies ...................................................................................................493
17.1. Introduction .................................................................................................493
17.2. JSP & JSTL .................................................................................................493
View resolvers .............................................................................................493
'Plain-old' JSPs versus JSTL ..........................................................................494
Additional tags facilitating development ........................................................494
Using Spring's form tag library ......................................................................494
Configuration .......................................................................................494
The form tag ........................................................................................495
The input tag ........................................................................................496
The checkbox tag ..................................................................................496
The checkboxes tag ..............................................................................498
The radiobutton tag ...............................................................................498
The radiobuttons tag .............................................................................499
The password tag ..................................................................................499
The select tag .......................................................................................499
The option tag ......................................................................................500
The options tag .....................................................................................500
The textarea tag ....................................................................................501
The hidden tag ......................................................................................501
The errors tag .......................................................................................502
HTTP Method Conversion ....................................................................504
HTML5 Tags .......................................................................................504
17.3. Tiles ............................................................................................................505
Dependencies ...............................................................................................505
How to integrate Tiles ...................................................................................505
UrlBasedViewResolver .........................................................................506
Spring Framework
3.1 Reference Documentation xvi
ResourceBundleViewResolver ..............................................................506
SimpleSpringPreparerFactory and SpringBeanPreparerFactory ................506
17.4. Velocity & FreeMarker .................................................................................507
Dependencies ...............................................................................................507
Context configuration ...................................................................................507
Creating templates ........................................................................................508
Advanced configuration ................................................................................508
velocity.properties ................................................................................509
FreeMarker ..........................................................................................509
Bind support and form handling .....................................................................509
The bind macros ...................................................................................510
Simple binding .....................................................................................510
Form input generation macros ...............................................................511
HTML escaping and XHTML compliance .............................................515
17.5. XSLT ..........................................................................................................516
My First Words ............................................................................................516
Bean definitions ...................................................................................516
Standard MVC controller code ..............................................................516
Convert the model data to XML ............................................................517
Defining the view properties ..................................................................518
Document transformation ......................................................................518
Summary .....................................................................................................518
17.6. Document views (PDF/Excel) .......................................................................519
Introduction .................................................................................................519
Configuration and setup ................................................................................519
Document view definitions ....................................................................519
Controller code .....................................................................................520
Subclassing for Excel views ..................................................................520
Subclassing for PDF views ....................................................................521
17.7. JasperReports ...............................................................................................522
Dependencies ...............................................................................................522
Configuration ...............................................................................................522
Configuring the ViewResolver ..............................................................523
Configuring the Views ..........................................................................523
About Report Files ...............................................................................523
Using JasperReportsMultiFormatView ...................................................524
Populating the ModelAndView ......................................................................525
Working with Sub-Reports ............................................................................525
Configuring Sub-Report Files ................................................................526
Configuring Sub-Report Data Sources ...................................................526
Configuring Exporter Parameters ...................................................................527
17.8. Feed Views ..................................................................................................527
17.9. XML Marshalling View ................................................................................528
17.10. JSON Mapping View ..................................................................................528
18. Integrating with other web frameworks .....................................................................530
Spring Framework
3.1 Reference Documentation xvii
18.1. Introduction .................................................................................................530
18.2. Common configuration .................................................................................531
18.3. JavaServer Faces 1.1 and 1.2 .........................................................................532
DelegatingVariableResolver (JSF 1.1/1.2) ......................................................532
SpringBeanVariableResolver (JSF 1.1/1.2) .....................................................533
SpringBeanFacesELResolver (JSF 1.2+) ........................................................533
FacesContextUtils ........................................................................................534
18.4. Apache Struts 1.x and 2.x .............................................................................534
ContextLoaderPlugin ....................................................................................535
DelegatingRequestProcessor .................................................................536
DelegatingActionProxy .........................................................................536
ActionSupport Classes ..................................................................................537
18.5. WebWork 2.x ...............................................................................................537
18.6. Tapestry 3.x and 4.x .....................................................................................538
Injecting Spring-managed beans ....................................................................539
Dependency Injecting Spring Beans into Tapestry pages .........................540
Component definition files ....................................................................541
Adding abstract accessors ......................................................................542
Dependency Injecting Spring Beans into Tapestry pages - Tapestry 4.x style
.............................................................................................................544
18.7. Further Resources .........................................................................................545
19. Portlet MVC Framework .........................................................................................546
19.1. Introduction .................................................................................................546
Controllers - The C in MVC ..........................................................................547
Views - The V in MVC .................................................................................547
Web-scoped beans ........................................................................................548
19.2. The DispatcherPortlet ...................................................................................548
19.3. The ViewRendererServlet .............................................................................550
19.4. Controllers ...................................................................................................551
AbstractController and PortletContentGenerator .............................................551
Other simple controllers ................................................................................553
Command Controllers ...................................................................................553
PortletWrappingController ............................................................................554
19.5. Handler mappings ........................................................................................554
PortletModeHandlerMapping ........................................................................555
ParameterHandlerMapping ............................................................................556
PortletModeParameterHandlerMapping .........................................................556
Adding HandlerInterceptors ..........................................................................557
HandlerInterceptorAdapter ............................................................................557
ParameterMappingInterceptor .......................................................................557
19.6. Views and resolving them .............................................................................558
19.7. Multipart (file upload) support ......................................................................558
Using the PortletMultipartResolver ................................................................559
Handling a file upload in a form ....................................................................559
19.8. Handling exceptions .....................................................................................562
Spring Framework
3.1 Reference Documentation xviii
19.9. Annotation-based controller configuration .....................................................563
Setting up the dispatcher for annotation support ..............................................563
Defining a controller with @Controller ..........................................................563
Mapping requests with @RequestMapping .....................................................564
Supported handler method arguments ............................................................565
Binding request parameters to method parameters with @RequestParam ..........567
Providing a link to data from the model with @ModelAttribute .......................568
Specifying attributes to store in a Session with @SessionAttributes .................568
Customizing WebDataBinder initialization .....................................................569
Customizing data binding with @InitBinder ...........................................569
Configuring a custom WebBindingInitializer ..........................................569
19.10. Portlet application deployment ....................................................................570
VI. Integration ......................................................................................................................571
20. Remoting and web services using Spring ..................................................................572
20.1. Introduction .................................................................................................572
20.2. Exposing services using RMI ........................................................................573
Exporting the service using the RmiServiceExporter .......................................573
Linking in the service at the client .................................................................574
20.3. Using Hessian or Burlap to remotely call services via HTTP ...........................575
Wiring up the DispatcherServlet for Hessian and co. .......................................575
Exposing your beans by using the HessianServiceExporter ..............................575
Linking in the service on the client ................................................................576
Using Burlap ................................................................................................576
Applying HTTP basic authentication to a service exposed through Hessian or
Burlap ..........................................................................................................577
20.4. Exposing services using HTTP invokers ........................................................577
Exposing the service object ...........................................................................577
Linking in the service at the client .................................................................578
20.5. Web services ................................................................................................579
Exposing servlet-based web services using JAX-RPC .....................................580
Accessing web services using JAX-RPC ........................................................580
Registering JAX-RPC Bean Mappings ...........................................................582
Registering your own JAX-RPC Handler .......................................................583
Exposing servlet-based web services using JAX-WS ......................................583
Exporting standalone web services using JAX-WS .........................................584
Exporting web services using the JAX-WS RI's Spring support .......................585
Accessing web services using JAX-WS ..........................................................585
20.6. JMS .............................................................................................................586
Server-side configuration ..............................................................................587
Client-side configuration ...............................................................................588
20.7. Auto-detection is not implemented for remote interfaces .................................589
20.8. Considerations when choosing a technology ...................................................589
20.9. Accessing RESTful services on the Client ......................................................590
RestTemplate ...............................................................................................590
Working with the URI ..........................................................................592
Spring Framework
3.1 Reference Documentation xix
Dealing with request and response headers .............................................593
HTTP Message Conversion ...........................................................................593
StringHttpMessageConverter .................................................................594
FormHttpMessageConverter ..................................................................594
ByteArrayHttpMessageConverter ..........................................................594
MarshallingHttpMessageConverter ........................................................594
MappingJacksonHttpMessageConverter .................................................595
SourceHttpMessageConverter ...............................................................595
BufferedImageHttpMessageConverter ...................................................595
21. Enterprise JavaBeans (EJB) integration ....................................................................596
21.1. Introduction .................................................................................................596
21.2. Accessing EJBs ............................................................................................596
Concepts ......................................................................................................596
Accessing local SLSBs .................................................................................597
Accessing remote SLSBs ..............................................................................598
Accessing EJB 2.x SLSBs versus EJB 3 SLSBs ..............................................599
21.3. Using Spring's EJB implementation support classes ........................................599
EJB 2.x base classes .....................................................................................599
EJB 3 injection interceptor ............................................................................601
22. JMS (Java Message Service) ....................................................................................603
22.1. Introduction .................................................................................................603
22.2. Using Spring JMS ........................................................................................603
JmsTemplate ................................................................................................603
Connections .................................................................................................604
Caching Messaging Resources ...............................................................605
SingleConnectionFactory ......................................................................605
CachingConnectionFactory ...................................................................605
Destination Management ...............................................................................605
Message Listener Containers .........................................................................606
SimpleMessageListenerContainer ..........................................................607
DefaultMessageListenerContainer .........................................................607
Transaction management ...............................................................................607
22.3. Sending a Message .......................................................................................608
Using Message Converters ............................................................................609
SessionCallback and ProducerCallback ..........................................................610
22.4. Receiving a message .....................................................................................610
Synchronous Reception .................................................................................610
Asynchronous Reception - Message-Driven POJOs ........................................610
The SessionAwareMessageListener interface .................................................611
The MessageListenerAdapter ........................................................................611
Processing messages within transactions ........................................................613
22.5. Support for JCA Message Endpoints ..............................................................614
22.6. JMS Namespace Support ..............................................................................616
23. JMX .......................................................................................................................621
23.1. Introduction .................................................................................................621
Spring Framework
3.1 Reference Documentation xx
剩余839页未读,继续阅读
2011-08-23 上传
2007-11-07 上传
2013-11-28 上传
卧鱼涨姿势
- 粉丝: 0
- 资源: 9
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Angular实现MarcHayek简历展示应用教程
- Crossbow Spot最新更新 - 获取Chrome扩展新闻
- 量子管道网络优化与Python实现
- Debian系统中APT缓存维护工具的使用方法与实践
- Python模块AccessControl的Windows64位安装文件介绍
- 掌握最新*** Fisher资讯,使用Google Chrome扩展
- Ember应用程序开发流程与环境配置指南
- EZPCOpenSDK_v5.1.2_build***版本更新详情
- Postcode-Finder:利用JavaScript和Google Geocode API实现
- AWS商业交易监控器:航线行为分析与营销策略制定
- AccessControl-4.0b6压缩包详细使用教程
- Python编程实践与技巧汇总
- 使用Sikuli和Python打造颜色求解器项目
- .Net基础视频教程:掌握GDI绘图技术
- 深入理解数据结构与JavaScript实践项目
- 双子座在线裁判系统:提高编程竞赛效率
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功