没有合适的资源?快使用搜索试试~ 我知道了~
首页Spring Framework 4.2.1 Reference Documentation
"Spring Framework 4.2.1的最新PDS版参考文档"
Spring Framework是Java平台上一个广泛应用的开源框架,它提供了丰富的功能,用于构建高效、可维护的 enterprise 应用程序。4.2.1.RELEASE是该框架的一个稳定版本,包括了自2004年以来的持续改进和新特性。
### 1. 概览(Overview of Spring Framework)
1. **入门指南(Getting Started with Spring)**
- 安装与配置:介绍如何下载并设置Spring框架,包括添加依赖到项目中。
- 第一个Spring应用:引导用户创建一个简单的Spring应用程序,展示核心概念。
2. **Spring框架简介(Introduction to the Spring Framework)**
- 反转控制(Dependency Injection, DI)和控制反转(Inversion of Control, IoC):DI是Spring的核心特性,允许对象之间的依赖关系被外部化,提高了代码的可测试性和可重用性。
- **模块结构(Modules)**
- 核心容器(Core Container):包括Bean工厂(BeanFactory)和ApplicationContext,负责管理应用的bean及其生命周期。
- 面向切面编程(Aspect-Oriented Programming, AOP)与工具:提供面向切面的编程支持,实现跨切面的关注点,如日志、事务管理。
- 仪器化(Instrumentation):用于类加载器和内存分析工具的支持。
- 消息(Messaging):与消息传递系统集成,例如JMS,RabbitMQ等。
### 2. 核心容器(Core Container)
- **Bean工厂(BeanFactory)**:Spring的核心接口,负责初始化、配置、定位和管理对象。
- **ApplicationContext**:扩展BeanFactory,提供更全面的功能,如事件发布、国际化的支持,以及从各种源加载配置的能力。
### 3. 面向切面编程(AOP and Instrumentation)
- **切面(Aspects)**:定义关注点和它们如何模块化。
- **通知(Advices)**:在特定连接点上执行的操作,如前置通知、后置通知等。
- **切入点(Pointcuts)**:定义何时应用通知的规则。
- **代理(Proxies)**:Spring创建的代理对象来实现AOP功能。
### 4. 数据访问(Data Access)
- **JDBC抽象层**:简化数据库操作,提供事务管理和异常转换。
- **ORM支持**:集成了Hibernate, JPA, iBatis等流行的对象关系映射框架。
- **JMS支持**:通过API处理消息队列,实现异步通信。
### 5. Web支持
- **Spring MVC**:用于构建Web应用程序的模型-视图-控制器框架。
- **WebSocket支持**:提供对WebSocket协议的支持,实现双向通信。
- **RESTful服务**:创建和消费RESTful Web服务的工具。
### 6. 其他特性
- **测试支持**:方便集成测试,包括Mock对象和TestContext框架。
- **安全集成**:与Spring Security等框架集成,提供身份验证和授权。
- **任务调度**:通过TaskExecutor和TaskScheduler接口处理定时任务。
这个PDS版参考文档将深入探讨这些主题,提供详细的API参考、配置示例和最佳实践,帮助开发者充分利用Spring Framework 4.2.1的强大功能。无论你是初学者还是经验丰富的开发人员,都可以从中受益匪浅。
Spring Framework Reference Documentation
4.2.1.RELEASE Spring Framework xvi
Request Parameters and Header Values ................................................. 480
Defining @RequestMapping handler methods .................................................. 480
Supported method argument types .......................................................... 480
Supported method return types ............................................................... 483
Binding request parameters to method parameters with @RequestParam ... 484
Mapping the request body with the @RequestBody annotation .................. 484
Mapping the response body with the @ResponseBody annotation ............. 485
Creating REST Controllers with the @RestController annotation ................ 486
Using HttpEntity ...................................................................................... 486
Using @ModelAttribute on a method ....................................................... 486
Using @ModelAttribute on a method argument ......................................... 487
Using @SessionAttributes to store model attributes in the HTTP session
between requests ................................................................................... 489
Working with "application/x-www-form-urlencoded" data ............................ 489
Mapping cookie values with the @CookieValue annotation ........................ 490
Mapping request header attributes with the @RequestHeader annotation ... 490
Method Parameters And Type Conversion ............................................... 491
Customizing WebDataBinder initialization ................................................. 491
Advising controllers with @ControllerAdvice ............................................. 492
Jackson Serialization View Support ......................................................... 493
Jackson JSONP Support ........................................................................ 494
Asynchronous Request Processing .................................................................. 495
Exception Handling for Async Requests ................................................... 496
Intercepting Async Requests ................................................................... 497
HTTP Streaming ..................................................................................... 497
HTTP Streaming With Server-Sent Events ............................................... 497
HTTP Streaming Directly To The OutputStream ....................................... 498
Configuring Asynchronous Request Processing ........................................ 498
Testing Controllers ......................................................................................... 499
21.4. Handler mappings .......................................................................................... 499
Intercepting requests with a HandlerInterceptor ................................................ 500
21.5. Resolving views ............................................................................................. 502
Resolving views with the ViewResolver interface .............................................. 502
Chaining ViewResolvers ................................................................................. 504
Redirecting to Views ....................................................................................... 504
RedirectView .......................................................................................... 505
The redirect: prefix ................................................................................. 506
The forward: prefix ................................................................................. 506
ContentNegotiatingViewResolver ..................................................................... 506
21.6. Using flash attributes ..................................................................................... 509
21.7. Building URIs ................................................................................................. 510
Building URIs to Controllers and methods ........................................................ 510
Building URIs to Controllers and methods from views ....................................... 511
21.8. Using locales ................................................................................................. 512
Obtaining Time Zone Information .................................................................... 513
AcceptHeaderLocaleResolver .......................................................................... 513
CookieLocaleResolver ..................................................................................... 513
SessionLocaleResolver ................................................................................... 513
LocaleChangeInterceptor ................................................................................ 513
21.9. Using themes ................................................................................................ 514
Spring Framework Reference Documentation
4.2.1.RELEASE Spring Framework xvii
Overview of themes ........................................................................................ 514
Defining themes ............................................................................................. 514
Theme resolvers ............................................................................................. 515
21.10. Spring’s multipart (file upload) support ........................................................... 515
Introduction .................................................................................................... 515
Using a MultipartResolver with Commons FileUpload ........................................ 516
Using a MultipartResolver with Servlet 3.0 ....................................................... 516
Handling a file upload in a form ...................................................................... 516
Handling a file upload request from programmatic clients .................................. 517
21.11. Handling exceptions ..................................................................................... 518
HandlerExceptionResolver .............................................................................. 518
@ExceptionHandler ........................................................................................ 519
Handling Standard Spring MVC Exceptions ...................................................... 519
Annotating Business Exceptions With @ResponseStatus .................................. 520
Customizing the Default Servlet Container Error Page ...................................... 520
21.12. Web Security ............................................................................................... 521
21.13. Convention over configuration support ........................................................... 521
The Controller ControllerClassNameHandlerMapping ........................................ 522
The Model ModelMap (ModelAndView) ............................................................ 523
The View - RequestToViewNameTranslator ..................................................... 524
21.14. HTTP caching support .................................................................................. 525
Cache-Control HTTP header ........................................................................... 525
HTTP caching support for static resources ....................................................... 526
Support for the Cache-Control, ETag and Last-Modified response headers in
Controllers ...................................................................................................... 526
Shallow ETag support ..................................................................................... 527
21.15. Code-based Servlet container initialization ..................................................... 528
21.16. Configuring Spring MVC ............................................................................... 530
Enabling the MVC Java Config or the MVC XML Namespace ............................ 530
Customizing the Provided Configuration ........................................................... 532
Conversion and Formatting ............................................................................. 532
Validation ....................................................................................................... 533
Interceptors .................................................................................................... 534
Content Negotiation ........................................................................................ 535
View Controllers ............................................................................................. 536
View Resolvers .............................................................................................. 536
Serving of Resources ..................................................................................... 538
Falling Back On the "Default" Servlet To Serve Resources ................................ 540
Path Matching ................................................................................................ 541
Message Converters ....................................................................................... 542
Advanced Customizations with MVC Java Config ............................................. 543
Advanced Customizations with the MVC Namespace ........................................ 544
22. View technologies ..................................................................................................... 545
22.1. Introduction .................................................................................................... 545
22.2. Thymeleaf ..................................................................................................... 545
22.3. Groovy Markup Templates .............................................................................. 545
Configuration .................................................................................................. 545
Example ......................................................................................................... 546
22.4. Velocity & FreeMarker .................................................................................... 546
Dependencies ................................................................................................ 546
Spring Framework Reference Documentation
4.2.1.RELEASE Spring Framework xviii
Context configuration ...................................................................................... 546
Creating templates ......................................................................................... 547
Advanced configuration ................................................................................... 547
velocity.properties ................................................................................... 547
FreeMarker ............................................................................................. 548
Bind support and form handling ....................................................................... 548
The bind macros .................................................................................... 548
Simple binding ........................................................................................ 548
Form input generation macros ................................................................. 549
HTML escaping and XHTML compliance ................................................. 553
22.5. JSP & JSTL .................................................................................................. 553
View resolvers ................................................................................................ 553
'Plain-old' JSPs versus JSTL ........................................................................... 554
Additional tags facilitating development ............................................................ 554
Using Spring’s form tag library ........................................................................ 554
Configuration .......................................................................................... 555
The form tag .......................................................................................... 555
The input tag .......................................................................................... 556
The checkbox tag ................................................................................... 556
The checkboxes tag ............................................................................... 558
The radiobutton tag ................................................................................ 558
The radiobuttons tag ............................................................................... 558
The password tag ................................................................................... 559
The select tag ........................................................................................ 559
The option tag ........................................................................................ 559
The options tag ...................................................................................... 560
The textarea tag ..................................................................................... 561
The hidden tag ....................................................................................... 561
The errors tag ........................................................................................ 561
HTTP Method Conversion ....................................................................... 563
HTML5 Tags .......................................................................................... 564
22.6. Script templates ............................................................................................. 564
Dependencies ................................................................................................ 564
How to integrate script based templating .......................................................... 565
22.7. XML Marshalling View .................................................................................... 567
22.8. Tiles .............................................................................................................. 567
Dependencies ................................................................................................ 567
How to integrate Tiles ..................................................................................... 567
UrlBasedViewResolver ............................................................................ 568
ResourceBundleViewResolver ................................................................. 568
SimpleSpringPreparerFactory and SpringBeanPreparerFactory ................. 569
22.9. XSLT ............................................................................................................. 569
My First Words ............................................................................................... 569
Bean definitions ...................................................................................... 569
Standard MVC controller code ................................................................. 570
Document transformation ........................................................................ 570
22.10. Document views (PDF/Excel) ........................................................................ 571
Introduction .................................................................................................... 571
Configuration and setup .................................................................................. 571
Document view definitions ....................................................................... 571
Spring Framework Reference Documentation
4.2.1.RELEASE Spring Framework xix
Controller code ....................................................................................... 572
Subclassing for Excel views .................................................................... 572
Subclassing for PDF views ..................................................................... 573
22.11. JasperReports .............................................................................................. 573
Dependencies ................................................................................................ 574
Configuration .................................................................................................. 574
Configuring the ViewResolver .................................................................. 574
Configuring the Views ............................................................................. 574
About Report Files .................................................................................. 575
Using JasperReportsMultiFormatView ...................................................... 575
Populating the ModelAndView ......................................................................... 576
Working with Sub-Reports ............................................................................... 577
Configuring Sub-Report Files .................................................................. 577
Configuring Sub-Report Data Sources ..................................................... 577
Configuring Exporter Parameters ..................................................................... 578
22.12. Feed Views ................................................................................................. 578
22.13. JSON Mapping View .................................................................................... 579
22.14. XML Mapping View ...................................................................................... 579
23. Integrating with other web frameworks ....................................................................... 580
23.1. Introduction .................................................................................................... 580
23.2. Common configuration ................................................................................... 581
23.3. JavaServer Faces 1.2 .................................................................................... 582
SpringBeanFacesELResolver (JSF 1.2+) ......................................................... 582
FacesContextUtils ........................................................................................... 582
23.4. Apache Struts 2.x .......................................................................................... 582
23.5. Tapestry 5.x .................................................................................................. 583
23.6. Further Resources ......................................................................................... 583
24. Portlet MVC Framework ............................................................................................ 584
24.1. Introduction .................................................................................................... 584
Controllers - The C in MVC ............................................................................ 585
Views - The V in MVC .................................................................................... 585
Web-scoped beans ......................................................................................... 585
24.2. The DispatcherPortlet ..................................................................................... 585
24.3. The ViewRendererServlet ............................................................................... 587
24.4. Controllers ..................................................................................................... 588
AbstractController and PortletContentGenerator ............................................... 589
Other simple controllers .................................................................................. 590
Command Controllers ..................................................................................... 590
PortletWrappingController ................................................................................ 591
24.5. Handler mappings .......................................................................................... 591
PortletModeHandlerMapping ............................................................................ 592
ParameterHandlerMapping .............................................................................. 592
PortletModeParameterHandlerMapping ............................................................ 593
Adding HandlerInterceptors ............................................................................. 593
HandlerInterceptorAdapter ............................................................................... 594
ParameterMappingInterceptor .......................................................................... 594
24.6. Views and resolving them .............................................................................. 594
24.7. Multipart (file upload) support ......................................................................... 594
Using the PortletMultipartResolver ................................................................... 595
Handling a file upload in a form ...................................................................... 595
Spring Framework Reference Documentation
4.2.1.RELEASE Spring Framework xx
24.8. Handling exceptions ....................................................................................... 599
24.9. Annotation-based controller configuration ........................................................ 599
Setting up the dispatcher for annotation support ............................................... 599
Defining a controller with @Controller .............................................................. 600
Mapping requests with @RequestMapping ....................................................... 600
Supported handler method arguments ............................................................. 602
Binding request parameters to method parameters with @RequestParam .......... 603
Providing a link to data from the model with @ModelAttribute ............................ 603
Specifying attributes to store in a Session with @SessionAttributes .................... 604
Customizing WebDataBinder initialization ......................................................... 604
Customizing data binding with @InitBinder ............................................... 605
Configuring a custom WebBindingInitializer .............................................. 605
24.10. Portlet application deployment ...................................................................... 605
25. WebSocket Support .................................................................................................. 607
25.1. Introduction .................................................................................................... 607
WebSocket Fallback Options ........................................................................... 607
A Messaging Architecture ............................................................................... 608
Sub-Protocol Support in WebSocket ................................................................ 608
Should I Use WebSocket? .............................................................................. 608
25.2. WebSocket API ............................................................................................. 609
Create and Configure a WebSocketHandler ..................................................... 609
Customizing the WebSocket Handshake .......................................................... 610
WebSocketHandler Decoration ........................................................................ 611
Deployment Considerations ............................................................................. 611
Configuring the WebSocket Engine ................................................................. 612
Configuring allowed origins ............................................................................. 614
25.3. SockJS Fallback Options ................................................................................ 615
Overview of SockJS ....................................................................................... 615
Enable SockJS ............................................................................................... 616
HTTP Streaming in IE 8, 9: Ajax/XHR vs IFrame .............................................. 617
Heartbeat Messages ....................................................................................... 618
Servlet 3 Async Requests ............................................................................... 618
CORS Headers for SockJS ............................................................................. 619
SockJS Client ................................................................................................. 619
25.4. STOMP Over WebSocket Messaging Architecture ........................................... 621
Overview of STOMP ....................................................................................... 621
Enable STOMP over WebSocket ..................................................................... 622
Flow of Messages .......................................................................................... 624
Annotation Message Handling ......................................................................... 626
Sending Messages ......................................................................................... 628
Simple Broker ................................................................................................ 628
Full-Featured Broker ....................................................................................... 628
Connections To Full-Featured Broker .............................................................. 629
Using Dot as Separator in @MessageMapping Destinations .............................. 630
Authentication ................................................................................................. 631
User Destinations ........................................................................................... 632
Listening To ApplicationContext Events and Intercepting Messages ................... 633
STOMP Client ................................................................................................ 635
WebSocket Scope .......................................................................................... 636
Configuration and Performance ....................................................................... 637
剩余886页未读,继续阅读
点击了解资源详情
154 浏览量
点击了解资源详情
104 浏览量
101 浏览量
184 浏览量
2015-12-01 上传
137 浏览量
130 浏览量
dqjytt
- 粉丝: 2
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- SDE工具包-最新版
- undertow-cdi-jaxrs-rest-api-json:JEE应用程序示例+ CDI +具有Undertow + REST + JSON的嵌入式Servlet容器
- cubeJSgames-开源
- 你抓不到我
- lpc13-exploit:Golang中的最小UART客户端,可转储锁定在CRP1的LPC1343芯片
- sciencewarp-unexpo:专为UNEXPO Vicerrectorado波多黎各奥尔达斯大学的社区服务项目而开发的项目
- ORMDroid是适用于您的Android应用程序的简单ORM持久性框架。-Android开发
- roxLife-开源
- Sqlite 数据库文件更新机制
- 经文汇编软件,自学的好帮手
- securityjwt-old.zip
- git-rdm:Git版本控制系统的研究数据管理插件
- matlab标注字体代码-ScientificFigurePlot:Matlab代码,用于方便地绘制2Dcuves(包括颜色,标签,字体等)
- EmployeeManagement-java
- interactive-coding-tutorial:交互式js,画布
- 长按碎屏效果
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功