没有合适的资源?快使用搜索试试~ 我知道了~
首页Spring框架3.0参考文档
Spring框架3.0参考文档
需积分: 0 0 下载量 175 浏览量
更新于2024-07-30
收藏 4.16MB PDF 举报
"Spring3.0框架参考文档"
Spring3.0是Java开发中广泛使用的开源框架,它提供了许多核心功能和服务,以简化企业级应用程序的构建。本文档详细介绍了Spring3.0的主要特性、模块组成以及使用场景。
1. **简介**
Spring框架的核心理念是依赖注入(Dependency Injection, DI)和控制反转(Inversion of Control, IoC)。这两个概念旨在减少代码之间的耦合度,使得组件之间可以更加灵活地交互。通过IoC容器,Spring能够管理对象的生命周期和装配,使得开发者无需在代码中硬编码依赖关系。
2. **模块**
- **核心容器**:包括Bean工厂和ApplicationContext,它们是Spring的基础,负责创建、配置和管理应用中的对象。
- **数据访问/集成**:支持各种数据访问技术,如JDBC、ORM(Hibernate、JPA等)、OXM(对象-XML映射)和JMS。
- **Web**:提供Web MVC框架,用于构建Web应用程序,同时支持portlet环境。
- **面向切面编程(AOP)和Instrumentation**:支持声明式事务管理、日志记录和其他跨切面关注点的实现。
- **测试**:提供单元测试和集成测试的支持,便于进行应用的全面验证。
3. **使用场景**
Spring框架适用于多种类型的项目,例如:
- 单体应用:通过IoC和AOP来解耦和管理复杂性。
- 分层架构:在服务层、数据访问层和表示层之间提供松耦合。
- 微服务:Spring Boot和Spring Cloud可以帮助构建和管理独立的服务。
4. **依赖管理与命名规范**
- **Spring依赖**:Spring框架与其他库的依赖关系通常遵循特定的版本管理策略,以确保兼容性和稳定性。
- **Maven依赖管理**:如果你使用Maven作为构建工具,Spring的依赖可以通过Maven的BOM(Bill of Materials)来管理,确保版本一致性。
- **Ivy依赖管理**:对于使用Apache Ivy的项目,Spring同样提供了相应的配置,方便管理依赖。
5. **日志**
Spring支持多种日志框架,如Log4j、Java Util Logging和SLF4J,允许开发者根据项目需求选择合适的日志实现。
在Spring3.0中,开发者可以利用这些模块和特性来构建高效、可扩展且易于维护的应用程序。无论是简单的数据访问还是复杂的分布式系统,Spring都能提供强大的支持。同时,文档中的"Table of Contents"章节还包含了更深入的主题,涵盖了Spring的更多细节,如配置、事件处理、任务调度等,这些都是构建基于Spring3.0的应用时需要掌握的关键知识。
![](https://csdnimg.cn/release/download_crawler_static/3846044/bg10.jpg)
The View - RequestToViewNameTranslator ..................................................485
16.12. ETag support ..............................................................................................486
16.13. Configuring Spring MVC ............................................................................487
mvc:annotation-driven ..................................................................................487
mvc:interceptors ...........................................................................................488
mvc:view-controller ......................................................................................489
mvc:resources ..............................................................................................489
mvc:default-servlet-handler ...........................................................................490
16.14. More Spring Web MVC Resources ..............................................................491
17. View technologies ...................................................................................................492
17.1. Introduction .................................................................................................492
17.2. JSP & JSTL .................................................................................................492
View resolvers .............................................................................................492
'Plain-old' JSPs versus JSTL ..........................................................................493
Additional tags facilitating development ........................................................493
Using Spring's form tag library ......................................................................493
Configuration .......................................................................................493
The form tag ........................................................................................494
The input tag ........................................................................................495
The checkbox tag ..................................................................................495
The checkboxes tag ..............................................................................497
The radiobutton tag ...............................................................................497
The radiobuttons tag .............................................................................498
The password tag ..................................................................................498
The select tag .......................................................................................498
The option tag ......................................................................................499
The options tag .....................................................................................499
The textarea tag ....................................................................................500
The hidden tag ......................................................................................500
The errors tag .......................................................................................501
HTTP Method Conversion ....................................................................503
17.3. Tiles ............................................................................................................503
Dependencies ...............................................................................................504
How to integrate Tiles ...................................................................................504
UrlBasedViewResolver .........................................................................504
ResourceBundleViewResolver ..............................................................505
SimpleSpringPreparerFactory and SpringBeanPreparerFactory ................505
17.4. Velocity & FreeMarker .................................................................................506
Dependencies ...............................................................................................506
Context configuration ...................................................................................506
Creating templates ........................................................................................507
Advanced configuration ................................................................................507
velocity.properties ................................................................................507
FreeMarker ..........................................................................................508
Bind support and form handling .....................................................................508
Spring Framework
3.1 Reference Documentation xvi
![](https://csdnimg.cn/release/download_crawler_static/3846044/bg11.jpg)
The bind macros ...................................................................................508
Simple binding .....................................................................................509
Form input generation macros ...............................................................510
HTML escaping and XHTML compliance .............................................514
17.5. XSLT ..........................................................................................................515
My First Words ............................................................................................515
Bean definitions ...................................................................................515
Standard MVC controller code ..............................................................515
Convert the model data to XML ............................................................516
Defining the view properties ..................................................................516
Document transformation ......................................................................517
Summary .....................................................................................................517
17.6. Document views (PDF/Excel) .......................................................................518
Introduction .................................................................................................518
Configuration and setup ................................................................................518
Document view definitions ....................................................................518
Controller code .....................................................................................518
Subclassing for Excel views ..................................................................519
Subclassing for PDF views ....................................................................520
17.7. JasperReports ...............................................................................................521
Dependencies ...............................................................................................521
Configuration ...............................................................................................521
Configuring the ViewResolver ..............................................................521
Configuring the Views ..........................................................................522
About Report Files ...............................................................................522
Using JasperReportsMultiFormatView ...................................................522
Populating the ModelAndView ......................................................................523
Working with Sub-Reports ............................................................................524
Configuring Sub-Report Files ................................................................524
Configuring Sub-Report Data Sources ...................................................525
Configuring Exporter Parameters ...................................................................525
17.8. Feed Views ..................................................................................................526
17.9. XML Marshalling View ................................................................................527
17.10. JSON Mapping View ..................................................................................527
18. Integrating with other web frameworks .....................................................................528
18.1. Introduction .................................................................................................528
18.2. Common configuration .................................................................................529
18.3. JavaServer Faces 1.1 and 1.2 .........................................................................530
DelegatingVariableResolver (JSF 1.1/1.2) ......................................................530
SpringBeanVariableResolver (JSF 1.1/1.2) .....................................................531
SpringBeanFacesELResolver (JSF 1.2+) ........................................................531
FacesContextUtils ........................................................................................532
18.4. Apache Struts 1.x and 2.x .............................................................................532
ContextLoaderPlugin ....................................................................................533
DelegatingRequestProcessor .................................................................533
Spring Framework
3.1 Reference Documentation xvii
![](https://csdnimg.cn/release/download_crawler_static/3846044/bg12.jpg)
DelegatingActionProxy .........................................................................534
ActionSupport Classes ..................................................................................535
18.5. WebWork 2.x ...............................................................................................535
18.6. Tapestry 3.x and 4.x .....................................................................................536
Injecting Spring-managed beans ....................................................................537
Dependency Injecting Spring Beans into Tapestry pages .........................538
Component definition files ....................................................................539
Adding abstract accessors ......................................................................540
Dependency Injecting Spring Beans into Tapestry pages - Tapestry 4.x style
.............................................................................................................542
18.7. Further Resources .........................................................................................543
19. Portlet MVC Framework .........................................................................................544
19.1. Introduction .................................................................................................544
Controllers - The C in MVC ..........................................................................545
Views - The V in MVC .................................................................................545
Web-scoped beans ........................................................................................546
19.2. The DispatcherPortlet ...................................................................................546
19.3. The ViewRendererServlet .............................................................................548
19.4. Controllers ...................................................................................................549
AbstractController and PortletContentGenerator .............................................549
Other simple controllers ................................................................................551
Command Controllers ...................................................................................551
PortletWrappingController ............................................................................552
19.5. Handler mappings ........................................................................................552
PortletModeHandlerMapping ........................................................................553
ParameterHandlerMapping ............................................................................554
PortletModeParameterHandlerMapping .........................................................554
Adding HandlerInterceptors ..........................................................................555
HandlerInterceptorAdapter ............................................................................555
ParameterMappingInterceptor .......................................................................555
19.6. Views and resolving them .............................................................................556
19.7. Multipart (file upload) support ......................................................................556
Using the PortletMultipartResolver ................................................................557
Handling a file upload in a form ....................................................................557
19.8. Handling exceptions .....................................................................................560
19.9. Annotation-based controller configuration .....................................................561
Setting up the dispatcher for annotation support ..............................................561
Defining a controller with @Controller ..........................................................561
Mapping requests with @RequestMapping .....................................................562
Supported handler method arguments ............................................................563
Binding request parameters to method parameters with @RequestParam ..........565
Providing a link to data from the model with @ModelAttribute .......................566
Specifying attributes to store in a Session with @SessionAttributes .................566
Customizing WebDataBinder initialization .....................................................567
Customizing data binding with @InitBinder ...........................................567
Spring Framework
3.1 Reference Documentation xviii
![](https://csdnimg.cn/release/download_crawler_static/3846044/bg13.jpg)
Configuring a custom WebBindingInitializer ..........................................567
19.10. Portlet application deployment ....................................................................568
VI. Integration ......................................................................................................................569
20. Remoting and web services using Spring ..................................................................570
20.1. Introduction .................................................................................................570
20.2. Exposing services using RMI ........................................................................571
Exporting the service using the RmiServiceExporter .......................................571
Linking in the service at the client .................................................................572
20.3. Using Hessian or Burlap to remotely call services via HTTP ...........................573
Wiring up the DispatcherServlet for Hessian and co. .......................................573
Exposing your beans by using the HessianServiceExporter ..............................573
Linking in the service on the client ................................................................574
Using Burlap ................................................................................................574
Applying HTTP basic authentication to a service exposed through Hessian or
Burlap ..........................................................................................................575
20.4. Exposing services using HTTP invokers ........................................................575
Exposing the service object ...........................................................................575
Linking in the service at the client .................................................................576
20.5. Web services ................................................................................................577
Exposing servlet-based web services using JAX-RPC .....................................578
Accessing web services using JAX-RPC ........................................................578
Registering JAX-RPC Bean Mappings ...........................................................580
Registering your own JAX-RPC Handler .......................................................581
Exposing servlet-based web services using JAX-WS ......................................581
Exporting standalone web services using JAX-WS .........................................582
Exporting web services using the JAX-WS RI's Spring support .......................583
Accessing web services using JAX-WS ..........................................................583
20.6. JMS .............................................................................................................584
Server-side configuration ..............................................................................585
Client-side configuration ...............................................................................586
20.7. Auto-detection is not implemented for remote interfaces .................................587
20.8. Considerations when choosing a technology ...................................................587
20.9. Accessing RESTful services on the Client ......................................................588
RestTemplate ...............................................................................................588
Dealing with request and response headers .............................................590
HTTP Message Conversion ...........................................................................591
StringHttpMessageConverter .................................................................591
FormHttpMessageConverter ..................................................................591
ByteArrayMessageConverter .................................................................592
MarshallingHttpMessageConverter ........................................................592
MappingJacksonHttpMessageConverter .................................................592
SourceHttpMessageConverter ...............................................................592
BufferedImageHttpMessageConverter ...................................................592
21. Enterprise JavaBeans (EJB) integration ....................................................................593
21.1. Introduction .................................................................................................593
Spring Framework
3.1 Reference Documentation xix
![](https://csdnimg.cn/release/download_crawler_static/3846044/bg14.jpg)
21.2. Accessing EJBs ............................................................................................593
Concepts ......................................................................................................593
Accessing local SLSBs .................................................................................594
Accessing remote SLSBs ..............................................................................595
Accessing EJB 2.x SLSBs versus EJB 3 SLSBs ..............................................596
21.3. Using Spring's EJB implementation support classes ........................................596
EJB 2.x base classes .....................................................................................596
EJB 3 injection interceptor ............................................................................598
22. JMS (Java Message Service) ....................................................................................600
22.1. Introduction .................................................................................................600
22.2. Using Spring JMS ........................................................................................600
JmsTemplate ................................................................................................600
Connections .................................................................................................601
Caching Messaging Resources ...............................................................602
SingleConnectionFactory ......................................................................602
CachingConnectionFactory ...................................................................602
Destination Management ...............................................................................602
Message Listener Containers .........................................................................603
SimpleMessageListenerContainer ..........................................................604
DefaultMessageListenerContainer .........................................................604
Transaction management ...............................................................................604
22.3. Sending a Message .......................................................................................605
Using Message Converters ............................................................................606
SessionCallback and ProducerCallback ..........................................................607
22.4. Receiving a message .....................................................................................607
Synchronous Reception .................................................................................607
Asynchronous Reception - Message-Driven POJOs ........................................607
The SessionAwareMessageListener interface .................................................608
The MessageListenerAdapter ........................................................................608
Processing messages within transactions ........................................................610
22.5. Support for JCA Message Endpoints ..............................................................611
22.6. JMS Namespace Support ..............................................................................613
23. JMX .......................................................................................................................618
23.1. Introduction .................................................................................................618
23.2. Exporting your beans to JMX ........................................................................618
Creating an MBeanServer .............................................................................619
Reusing an existing MBeanServer .................................................................620
Lazy-initialized MBeans ...............................................................................621
Automatic registration of MBeans .................................................................621
Controlling the registration behavior ..............................................................621
23.3. Controlling the management interface of your beans .......................................623
The MBeanInfoAssembler Interface ..............................................................623
Using Source-Level Metadata (JDK 5.0 annotations) ......................................623
Source-Level Metadata Types .......................................................................625
The AutodetectCapableMBeanInfoAssembler interface ...................................627
Spring Framework
3.1 Reference Documentation xx
剩余836页未读,继续阅读
2012-03-05 上传
156 浏览量
175 浏览量
2011-02-21 上传
2013-04-22 上传
107 浏览量
2010-03-18 上传
![](https://profile-avatar.csdnimg.cn/default.jpg!1)
this00
- 粉丝: 0
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![](https://csdnimg.cn/release/wenkucmsfe/public/img/voice.245cc511.png)
最新资源
- Windows到Linux入门教程:基础知识与安装指南
- 伟大架构师的抽象层次策略:简化IT解决方案
- JasperReport与iReport中文配置与使用详解
- Oracle分析函数详解与应用示例
- 无线局域网详解:概念、标准与技术应用
- Quartz定时任务开发指南
- <项目名称>操作手册编写规范详解
- Cadence Allegro PCB设计中文手册
- uVision2入门:Keil C51 开发工具教程
- 搭建虚拟域名:解析与配置详解
- DWR中文教程:快速掌握远程方法调用
- 测试人员的思考艺术:超越数字迷思
- WEKA3.5.5用户指南:数据探索与分析
- DWR教程:入门与实践
- EJB3.0实战教程:从入门到精通
- TMS320C6416:600MHz DSP在3G基站高速处理中的关键角色
安全验证
文档复制为VIP权益,开通VIP直接复制
![](https://csdnimg.cn/release/wenkucmsfe/public/img/green-success.6a4acb44.png)