没有合适的资源?快使用搜索试试~ 我知道了~
首页Spring Framework 参考手册: DependencyInjection 和 Inversion of Control
Spring Framework 参考手册: DependencyInjection 和 Inversion of Contro...
需积分: 10 1 下载量 188 浏览量
更新于2024-07-25
收藏 4.55MB PDF 举报
Spring Framework 参考文档
Spring Framework 是一个广泛使用的 Java 应用程序框架,它提供了一个综合的编程模型和配置机制,以帮助开发者快速构建企业级应用程序。该框架的设计目标是使开发者能够快速构建可维护、可扩展、灵活的应用程序。
**概述**
Spring Framework 是一个开源的Java应用程序框架,由 Rod Johnson 和 Juergen Hoeller 于 2004 年创建。该框架的主要目标是提供一个松散耦合的架构,使得应用程序的开发、测试和维护更加容易。
**依赖注入和控制反转**
Spring Framework 的核心概念是依赖注入(Dependency Injection)和控制反转(Inversion of Control)。依赖注入是一种设计模式,它允许组件之间松散耦合,使得应用程序更加灵活和可维护。控制反转则是指将控制权从应用程序中移除,交由框架来管理应用程序的生命周期。
**模块**
Spring Framework 由多个模块组成,每个模块负责不同的功能。这些模块包括:
* Core Container:提供了基本的依赖注入和控制反转机制。
* Data Access/Integration:提供了数据访问和集成机制,支持多种数据源和集成方式。
* Web:提供了 Web 应用程序开发功能,支持多种 Web 框架和协议。
* AOP 和 Instrumentation:提供了面向方面编程(Aspect-Oriented Programming)和 Instrumentation 机制,用于提供更好的应用程序性能和可维护性。
* Test:提供了测试机制,支持多种测试框架和协议。
**使用场景**
Spring Framework 可以应用于多种应用场景,包括:
* 企业级应用程序开发
* Web 应用程序开发
* 移动应用程序开发
* 微服务架构开发
**依赖管理和命名约定**
Spring Framework 提供了依赖管理机制,用于管理应用程序中的依赖关系。该机制支持多种依赖管理方式,包括 Maven、Gradle 等。同时,Spring Framework 还提供了命名约定机制,用于统一应用程序中的命名规则。
Spring Framework 是一个功能强大、灵活的应用程序框架,提供了多种功能和机制,以帮助开发者快速构建企业级应用程序。

Spring Framework
3.2.3.RELEASE
Spring Framework
Reference Documentation xvi
'Plain-old' JSPs versus JSTL ........................................................................... 511
Additional tags facilitating development ............................................................ 511
Using Spring's form tag library ........................................................................ 511
Configuration .......................................................................................... 511
The form tag ......................................................................................... 511
The input tag ....................................................................................... 513
The checkbox tag ................................................................................. 513
The checkboxes tag ............................................................................. 516
The radiobutton tag ........................................................................... 516
The radiobuttons tag ......................................................................... 517
The password tag ................................................................................. 517
The select tag ..................................................................................... 517
The option tag ..................................................................................... 518
The options tag ................................................................................... 518
The textarea tag ................................................................................. 519
The hidden tag ..................................................................................... 519
The errors tag ..................................................................................... 519
HTTP Method Conversion ....................................................................... 522
HTML5 Tags .......................................................................................... 523
18.3. Tiles .............................................................................................................. 523
Dependencies ................................................................................................ 523
How to integrate Tiles ..................................................................................... 523
UrlBasedViewResolver .................................................................... 524
ResourceBundleViewResolver ........................................................ 524
SimpleSpringPreparerFactory and
SpringBeanPreparerFactory ............................................................ 524
18.4. Velocity & FreeMarker .................................................................................... 525
Dependencies ................................................................................................ 525
Context configuration ...................................................................................... 525
Creating templates ......................................................................................... 526
Advanced configuration ................................................................................... 527
velocity.properties ................................................................................... 527
FreeMarker ............................................................................................. 527
Bind support and form handling ....................................................................... 528
The bind macros .................................................................................... 528
Simple binding ........................................................................................ 528
Form input generation macros ................................................................. 529
HTML escaping and XHTML compliance ................................................. 533
18.5. XSLT ............................................................................................................. 534
My First Words ............................................................................................... 534
Bean definitions ...................................................................................... 534
Standard MVC controller code ................................................................. 534
Convert the model data to XML ............................................................... 535
Defining the view properties .................................................................... 535
Document transformation ........................................................................ 536
Summary ....................................................................................................... 536
18.6. Document views (PDF/Excel) .......................................................................... 537
Introduction .................................................................................................... 537
Configuration and setup .................................................................................. 537
Document view definitions ....................................................................... 537

Spring Framework
3.2.3.RELEASE
Spring Framework
Reference Documentation xvii
Controller code ....................................................................................... 537
Subclassing for Excel views .................................................................... 537
Subclassing for PDF views ..................................................................... 539
18.7. JasperReports ............................................................................................... 540
Dependencies ................................................................................................ 540
Configuration .................................................................................................. 540
Configuring the ViewResolver .............................................................. 540
Configuring the Views ............................................................................ 540
About Report Files .................................................................................. 541
Using JasperReportsMultiFormatView ............................................. 541
Populating the ModelAndView ....................................................................... 542
Working with Sub-Reports ............................................................................... 543
Configuring Sub-Report Files .................................................................. 543
Configuring Sub-Report Data Sources ..................................................... 544
Configuring Exporter Parameters ..................................................................... 544
18.8. Feed Views ................................................................................................... 544
18.9. XML Marshalling View .................................................................................... 545
18.10. JSON Mapping View .................................................................................... 546
19. Integrating with other web frameworks ....................................................................... 547
19.1. Introduction .................................................................................................... 547
19.2. Common configuration ................................................................................... 548
19.3. JavaServer Faces 1.1 and 1.2 ........................................................................ 549
DelegatingVariableResolver (JSF 1.1/1.2) ........................................................ 549
SpringBeanVariableResolver (JSF 1.1/1.2) ....................................................... 550
SpringBeanFacesELResolver (JSF 1.2+) ......................................................... 550
FacesContextUtils ........................................................................................... 550
19.4. Apache Struts 1.x and 2.x .............................................................................. 551
ContextLoaderPlugin ....................................................................................... 551
DelegatingRequestProcessor ................................................................... 552
DelegatingActionProxy ............................................................................ 552
ActionSupport Classes .................................................................................... 553
19.5. WebWork 2.x ................................................................................................. 553
19.6. Tapestry 3.x and 4.x ...................................................................................... 554
Injecting Spring-managed beans ..................................................................... 555
Dependency Injecting Spring Beans into Tapestry pages ........................... 557
Component definition files ....................................................................... 558
Adding abstract accessors ...................................................................... 559
Dependency Injecting Spring Beans into Tapestry pages - Tapestry 4.x
style ....................................................................................................... 561
19.7. Further Resources ......................................................................................... 562
20. Portlet MVC Framework ............................................................................................ 563
20.1. Introduction .................................................................................................... 563
Controllers - The C in MVC ............................................................................ 564
Views - The V in MVC .................................................................................... 564
Web-scoped beans ......................................................................................... 564
20.2. The DispatcherPortlet ............................................................................ 564
20.3. The ViewRendererServlet ........................................................................ 566
20.4. Controllers ..................................................................................................... 567
AbstractController and PortletContentGenerator ............................. 568
Other simple controllers .................................................................................. 569

Spring Framework
3.2.3.RELEASE
Spring Framework
Reference Documentation xviii
Command Controllers ..................................................................................... 569
PortletWrappingController .................................................................... 570
20.5. Handler mappings .......................................................................................... 570
PortletModeHandlerMapping .................................................................... 571
ParameterHandlerMapping ........................................................................ 571
PortletModeParameterHandlerMapping .................................................. 572
Adding HandlerInterceptors ..................................................................... 572
HandlerInterceptorAdapter .................................................................... 573
ParameterMappingInterceptor ................................................................ 573
20.6. Views and resolving them .............................................................................. 573
20.7. Multipart (file upload) support ......................................................................... 574
Using the PortletMultipartResolver ....................................................... 574
Handling a file upload in a form ...................................................................... 575
20.8. Handling exceptions ....................................................................................... 578
20.9. Annotation-based controller configuration ........................................................ 578
Setting up the dispatcher for annotation support ............................................... 578
Defining a controller with @Controller .......................................................... 579
Mapping requests with @RequestMapping ..................................................... 580
Supported handler method arguments ............................................................. 581
Binding request parameters to method parameters with @RequestParam .......... 583
Providing a link to data from the model with @ModelAttribute ....................... 583
Specifying attributes to store in a Session with @SessionAttributes ............. 584
Customizing WebDataBinder initialization ...................................................... 584
Customizing data binding with @InitBinder .......................................... 584
Configuring a custom WebBindingInitializer ................................... 585
20.10. Portlet application deployment ...................................................................... 585
VI. Integration ......................................................................................................................... 586
21. Remoting and web services using Spring ................................................................... 587
21.1. Introduction .................................................................................................... 587
21.2. Exposing services using RMI .......................................................................... 588
Exporting the service using the RmiServiceExporter ................................... 588
Linking in the service at the client ................................................................... 589
21.3. Using Hessian or Burlap to remotely call services via HTTP .............................. 589
Wiring up the DispatcherServlet for Hessian and co. ................................. 589
Exposing your beans by using the HessianServiceExporter ....................... 590
Linking in the service on the client .................................................................. 591
Using Burlap .................................................................................................. 591
Applying HTTP basic authentication to a service exposed through Hessian or
Burlap ............................................................................................................ 591
21.4. Exposing services using HTTP invokers .......................................................... 592
Exposing the service object ............................................................................ 592
Linking in the service at the client ................................................................... 593
21.5. Web services ................................................................................................. 593
Exposing servlet-based web services using JAX-RPC ....................................... 594
Accessing web services using JAX-RPC .......................................................... 595
Registering JAX-RPC Bean Mappings ............................................................. 597
Registering your own JAX-RPC Handler .......................................................... 597
Exposing servlet-based web services using JAX-WS ........................................ 598
Exporting standalone web services using JAX-WS ........................................... 599
Exporting web services using the JAX-WS RI's Spring support .......................... 600

Spring Framework
3.2.3.RELEASE
Spring Framework
Reference Documentation xix
Accessing web services using JAX-WS ........................................................... 600
21.6. JMS .............................................................................................................. 601
Server-side configuration ................................................................................. 602
Client-side configuration .................................................................................. 603
21.7. Auto-detection is not implemented for remote interfaces ................................... 604
21.8. Considerations when choosing a technology .................................................... 604
21.9. Accessing RESTful services on the Client ....................................................... 605
RestTemplate ................................................................................................. 605
Working with the URI .............................................................................. 607
Dealing with request and response headers ............................................. 608
HTTP Message Conversion ............................................................................ 608
StringHttpMessageConverter ................................................................... 609
FormHttpMessageConverter .................................................................... 609
ByteArrayHttpMessageConverter ............................................................. 609
MarshallingHttpMessageConverter ........................................................... 609
MappingJackson2HttpMessageConverter (or
MappingJacksonHttpMessageConverter with Jackson 1.x) ........................ 610
SourceHttpMessageConverter ................................................................. 610
BufferedImageHttpMessageConverter ...................................................... 610
22. Enterprise JavaBeans (EJB) integration ..................................................................... 611
22.1. Introduction .................................................................................................... 611
22.2. Accessing EJBs ............................................................................................. 611
Concepts ........................................................................................................ 611
Accessing local SLSBs ................................................................................... 611
Accessing remote SLSBs ................................................................................ 613
Accessing EJB 2.x SLSBs versus EJB 3 SLSBs ............................................... 613
22.3. Using Spring's EJB implementation support classes ......................................... 614
EJB 2.x base classes ..................................................................................... 614
EJB 3 injection interceptor .............................................................................. 616
23. JMS (Java Message Service) .................................................................................... 618
23.1. Introduction .................................................................................................... 618
23.2. Using Spring JMS .......................................................................................... 618
JmsTemplate ................................................................................................ 618
Connections ................................................................................................... 619
Caching Messaging Resources ............................................................... 619
SingleConnectionFactory ......................................................................... 619
CachingConnectionFactory ...................................................................... 620
Destination Management ................................................................................. 620
Message Listener Containers .......................................................................... 621
SimpleMessageListenerContainer ............................................................ 621
DefaultMessageListenerContainer ............................................................ 621
Transaction management ................................................................................ 621
23.3. Sending a Message ....................................................................................... 622
Using Message Converters ............................................................................. 623
SessionCallback and ProducerCallback ................................................ 624
23.4. Receiving a message ..................................................................................... 624
Synchronous Reception .................................................................................. 624
Asynchronous Reception - Message-Driven POJOs .......................................... 624
The SessionAwareMessageListener interface ........................................... 625
The MessageListenerAdapter ................................................................... 626

Spring Framework
3.2.3.RELEASE
Spring Framework
Reference Documentation xx
Processing messages within transactions ........................................................ 627
23.5. Support for JCA Message Endpoints ............................................................... 628
23.6. JMS Namespace Support ............................................................................... 630
24. JMX ......................................................................................................................... 634
24.1. Introduction .................................................................................................... 634
24.2. Exporting your beans to JMX .......................................................................... 634
Creating an MBeanServer ............................................................................. 636
Reusing an existing MBeanServer ................................................................. 636
Lazy-initialized MBeans ................................................................................... 637
Automatic registration of MBeans .................................................................... 637
Controlling the registration behavior ................................................................. 638
24.3. Controlling the management interface of your beans ........................................ 639
The MBeanInfoAssembler Interface ............................................................. 639
Using Source-Level Metadata (JDK 5.0 annotations) ........................................ 639
Source-Level Metadata Types ......................................................................... 641
The AutodetectCapableMBeanInfoAssembler interface ............................ 643
Defining management interfaces using Java interfaces ..................................... 643
Using MethodNameBasedMBeanInfoAssembler ........................................... 645
24.4. Controlling the ObjectNames for your beans .................................................. 645
Reading ObjectNames from Properties ...................................................... 645
Using the MetadataNamingStrategy ........................................................... 646
Configuring annotation based MBean export .................................................... 647
24.5. JSR-160 Connectors ...................................................................................... 648
Server-side Connectors ................................................................................... 648
Client-side Connectors .................................................................................... 649
JMX over Burlap/Hessian/SOAP ...................................................................... 649
24.6. Accessing MBeans via Proxies ....................................................................... 649
24.7. Notifications ................................................................................................... 650
Registering Listeners for Notifications .............................................................. 650
Publishing Notifications ................................................................................... 654
24.8. Further Resources ......................................................................................... 656
25. JCA CCI .................................................................................................................. 657
25.1. Introduction .................................................................................................... 657
25.2. Configuring CCI ............................................................................................. 657
Connector configuration .................................................................................. 657
ConnectionFactory configuration in Spring ................................................. 658
Configuring CCI connections ........................................................................... 658
Using a single CCI connection ........................................................................ 659
25.3. Using Spring's CCI access support ................................................................. 660
Record conversion .......................................................................................... 660
The CciTemplate ......................................................................................... 661
DAO support .................................................................................................. 662
Automatic output record generation ................................................................. 662
Summary ....................................................................................................... 663
Using a CCI Connection and Interaction directly ...................................... 664
Example for CciTemplate usage ................................................................... 665
25.4. Modeling CCI access as operation objects ...................................................... 667
MappingRecordOperation .......................................................................... 667
MappingCommAreaOperation ...................................................................... 667
Automatic output record generation ................................................................. 668
剩余846页未读,继续阅读
231 浏览量
点击了解资源详情
点击了解资源详情
118 浏览量
2011-07-20 上传
102 浏览量
191 浏览量
219 浏览量
2020-07-17 上传

shensuoyao
- 粉丝: 8
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助

最新资源
- 服务器监控与日志管理的.p文件上传策略
- Visual C++网络编程案例源代码精解(前四章)
- Nihao3d:探索Flash3D学习的最佳实践平台
- Vue2日期选择器组件:vue2-datepicker的介绍与使用
- 全技术栈源码资源:灰色iso苹果风格WAP企业网站模板
- tcomb-form-redux-test开发环境启动指南
- 利用Ext JS与Asp.Net MVC 3实现CMS用户管理后台系统
- 英文版man手册CHM文件的介绍与应用
- 全面解析Firebase与OpenCV在网站开发中的应用教程
- 十大Android案例应用源码免费下载学习
- Java JDK 1.8 64位版下载安装教程
- 分析非对称三角后缘调制数字V-2控制Buck变换器
- android省市联动实现技巧与源码解析
- Qt中间件微型Web框架递归技术实现解析
- Hough变换项目:直线检测技术详解
- 变频器工程应用与参数设置实例分析
安全验证
文档复制为VIP权益,开通VIP直接复制
