没有合适的资源?快使用搜索试试~ 我知道了~
首页Spring Framework 4.2.4.RELEASE 完整参考文档
Spring Framework 4.2.4.RELEASE 是一款广泛使用的开源框架,由多位知名开发者共同维护,如Rod Johnson、Juergen Hoeller等。此版本的文档详细介绍了Spring框架的核心概念和技术特性,旨在帮助开发者深入了解并熟练应用该框架。
1. **概述** (Overview of Spring Framework)
- 这部分提供了Spring框架的总体介绍,包括其目的、设计理念和应用场景。Spring Framework主要关注依赖注入(Dependency Injection, DI)和控制反转(Inversion of Control, IoC),这两个核心原则简化了应用程序的架构设计和管理。
2. **入门指南** (Getting Started with Spring)
- 对于初次接触Spring的新手,这里有详细的步骤和教程,指导如何安装、配置和创建第一个Spring应用。这部分涵盖了基本配置、配置文件、bean的定义和管理等内容。
3. **Spring框架介绍** (Introduction to the Spring Framework)
- 在这一节,读者可以了解到Spring的模块划分,如核心容器(Core Container)、面向切面编程(AOP)与动态代理、消息传递(Messaging)等,展示了框架的灵活性和功能扩展性。
4. **核心容器** (Core Container)
- 这是Spring架构的基础,讲解了IoC容器如何管理对象的生命周期,以及如何通过配置来实现对象的自动装配。
5. **AOP与Instrumentation** (AOP and Instrumentation)
- 提供了关于Aspect Oriented Programming(AOP)的深入分析,包括通知(Advice)、切点(Pointcut)和连接点(Join Point)等概念,以及如何在Spring中利用这些技术进行代码优化和日志监控。
6. **数据访问与集成** (Data Access and Integration)
- 包括对JDBC、ORM(如Hibernate或MyBatis)以及事务管理的处理,展示了Spring如何与各种数据库系统无缝集成。
7. **其他模块** (Other Modules)
- 文档还涉及Spring Security(安全)、Spring MVC(Web开发)和Spring Boot(简化应用启动)等内容,覆盖了Spring生态系统的各个方面。
版权信息强调,用户可以免费复制和分发文档,但必须保留版权声明,并且不得收取任何费用。Spring Framework 4.2.4.RELEASE 的文档提供了一个全面的参考资源,适合所有层次的开发者,从新手到高级专家都能从中获益。随着技术的发展,虽然这是较早的一个版本,但其基础概念和原则仍然适用,并且对于理解后续版本的Spring框架具有重要意义。
Spring Framework Reference Documentation
4.2.4.RELEASE Spring Framework xvi
Producible Media Types .......................................................................... 482
Request Parameters and Header Values ................................................. 483
Defining @RequestMapping handler methods .................................................. 483
Supported method argument types .......................................................... 484
Supported method return types ............................................................... 486
Binding request parameters to method parameters with @RequestParam ... 487
Mapping the request body with the @RequestBody annotation .................. 487
Mapping the response body with the @ResponseBody annotation ............. 489
Creating REST Controllers with the @RestController annotation ................ 489
Using HttpEntity ...................................................................................... 489
Using @ModelAttribute on a method ....................................................... 490
Using @ModelAttribute on a method argument ......................................... 491
Using @SessionAttributes to store model attributes in the HTTP session
between requests ................................................................................... 492
Working with "application/x-www-form-urlencoded" data ............................ 493
Mapping cookie values with the @CookieValue annotation ........................ 493
Mapping request header attributes with the @RequestHeader annotation ... 494
Method Parameters And Type Conversion ............................................... 494
Customizing WebDataBinder initialization ................................................. 494
Advising controllers with @ControllerAdvice ............................................. 496
Jackson Serialization View Support ......................................................... 496
Jackson JSONP Support ........................................................................ 497
Asynchronous Request Processing .................................................................. 498
Exception Handling for Async Requests ................................................... 499
Intercepting Async Requests ................................................................... 500
HTTP Streaming ..................................................................................... 500
HTTP Streaming With Server-Sent Events ............................................... 500
HTTP Streaming Directly To The OutputStream ....................................... 501
Configuring Asynchronous Request Processing ........................................ 501
Testing Controllers ......................................................................................... 502
21.4. Handler mappings .......................................................................................... 502
Intercepting requests with a HandlerInterceptor ................................................ 503
21.5. Resolving views ............................................................................................. 505
Resolving views with the ViewResolver interface .............................................. 505
Chaining ViewResolvers ................................................................................. 507
Redirecting to Views ....................................................................................... 507
RedirectView .......................................................................................... 508
The redirect: prefix ................................................................................. 509
The forward: prefix ................................................................................. 509
ContentNegotiatingViewResolver ..................................................................... 509
21.6. Using flash attributes ..................................................................................... 511
21.7. Building URIs ................................................................................................. 512
Building URIs to Controllers and methods ........................................................ 513
Building URIs to Controllers and methods from views ....................................... 514
21.8. Using locales ................................................................................................. 515
Obtaining Time Zone Information .................................................................... 515
AcceptHeaderLocaleResolver .......................................................................... 515
CookieLocaleResolver ..................................................................................... 515
SessionLocaleResolver ................................................................................... 516
LocaleChangeInterceptor ................................................................................ 516
Spring Framework Reference Documentation
4.2.4.RELEASE Spring Framework xvii
21.9. Using themes ................................................................................................ 516
Overview of themes ........................................................................................ 516
Defining themes ............................................................................................. 517
Theme resolvers ............................................................................................. 517
21.10. Spring’s multipart (file upload) support ........................................................... 518
Introduction .................................................................................................... 518
Using a MultipartResolver with Commons FileUpload ........................................ 518
Using a MultipartResolver with Servlet 3.0 ....................................................... 518
Handling a file upload in a form ...................................................................... 519
Handling a file upload request from programmatic clients .................................. 520
21.11. Handling exceptions ..................................................................................... 521
HandlerExceptionResolver .............................................................................. 521
@ExceptionHandler ........................................................................................ 521
Handling Standard Spring MVC Exceptions ...................................................... 522
Annotating Business Exceptions With @ResponseStatus .................................. 523
Customizing the Default Servlet Container Error Page ...................................... 523
21.12. Web Security ............................................................................................... 524
21.13. Convention over configuration support ........................................................... 524
The Controller ControllerClassNameHandlerMapping ........................................ 524
The Model ModelMap (ModelAndView) ............................................................ 525
The View - RequestToViewNameTranslator ..................................................... 526
21.14. HTTP caching support .................................................................................. 527
Cache-Control HTTP header ........................................................................... 528
HTTP caching support for static resources ....................................................... 528
Support for the Cache-Control, ETag and Last-Modified response headers in
Controllers ...................................................................................................... 529
Shallow ETag support ..................................................................................... 530
21.15. Code-based Servlet container initialization ..................................................... 530
21.16. Configuring Spring MVC ............................................................................... 532
Enabling the MVC Java Config or the MVC XML Namespace ............................ 532
Customizing the Provided Configuration ........................................................... 534
Conversion and Formatting ............................................................................. 534
Validation ....................................................................................................... 535
Interceptors .................................................................................................... 537
Content Negotiation ........................................................................................ 537
View Controllers ............................................................................................. 538
View Resolvers .............................................................................................. 539
Serving of Resources ..................................................................................... 540
Falling Back On the "Default" Servlet To Serve Resources ................................ 542
Path Matching ................................................................................................ 543
Message Converters ....................................................................................... 544
Advanced Customizations with MVC Java Config ............................................. 545
Advanced Customizations with the MVC Namespace ........................................ 546
22. View technologies ..................................................................................................... 547
22.1. Introduction .................................................................................................... 547
22.2. Thymeleaf ..................................................................................................... 547
22.3. Groovy Markup Templates .............................................................................. 547
Configuration .................................................................................................. 547
Example ......................................................................................................... 548
22.4. Velocity & FreeMarker .................................................................................... 548
Spring Framework Reference Documentation
4.2.4.RELEASE Spring Framework xviii
Dependencies ................................................................................................ 548
Context configuration ...................................................................................... 548
Creating templates ......................................................................................... 549
Advanced configuration ................................................................................... 549
velocity.properties ................................................................................... 549
FreeMarker ............................................................................................. 550
Bind support and form handling ....................................................................... 550
The bind macros .................................................................................... 550
Simple binding ........................................................................................ 550
Form input generation macros ................................................................. 551
HTML escaping and XHTML compliance ................................................. 555
22.5. JSP & JSTL .................................................................................................. 555
View resolvers ................................................................................................ 555
'Plain-old' JSPs versus JSTL ........................................................................... 556
Additional tags facilitating development ............................................................ 556
Using Spring’s form tag library ........................................................................ 556
Configuration .......................................................................................... 557
The form tag .......................................................................................... 557
The input tag .......................................................................................... 558
The checkbox tag ................................................................................... 558
The checkboxes tag ............................................................................... 560
The radiobutton tag ................................................................................ 560
The radiobuttons tag ............................................................................... 560
The password tag ................................................................................... 561
The select tag ........................................................................................ 561
The option tag ........................................................................................ 561
The options tag ...................................................................................... 562
The textarea tag ..................................................................................... 563
The hidden tag ....................................................................................... 563
The errors tag ........................................................................................ 563
HTTP Method Conversion ....................................................................... 565
HTML5 Tags .......................................................................................... 566
22.6. Script templates ............................................................................................. 566
Dependencies ................................................................................................ 566
How to integrate script based templating .......................................................... 567
22.7. XML Marshalling View .................................................................................... 569
22.8. Tiles .............................................................................................................. 569
Dependencies ................................................................................................ 569
How to integrate Tiles ..................................................................................... 569
UrlBasedViewResolver ............................................................................ 570
ResourceBundleViewResolver ................................................................. 570
SimpleSpringPreparerFactory and SpringBeanPreparerFactory ................. 571
22.9. XSLT ............................................................................................................. 571
My First Words ............................................................................................... 572
Bean definitions ...................................................................................... 572
Standard MVC controller code ................................................................. 572
Document transformation ........................................................................ 573
22.10. Document views (PDF/Excel) ........................................................................ 573
Introduction .................................................................................................... 573
Configuration and setup .................................................................................. 574
Spring Framework Reference Documentation
4.2.4.RELEASE Spring Framework xix
Document view definitions ....................................................................... 574
Controller code ....................................................................................... 574
Subclassing for Excel views .................................................................... 574
Subclassing for PDF views ..................................................................... 576
22.11. JasperReports .............................................................................................. 576
Dependencies ................................................................................................ 576
Configuration .................................................................................................. 576
Configuring the ViewResolver .................................................................. 577
Configuring the Views ............................................................................. 577
About Report Files .................................................................................. 577
Using JasperReportsMultiFormatView ...................................................... 577
Populating the ModelAndView ......................................................................... 578
Working with Sub-Reports ............................................................................... 579
Configuring Sub-Report Files .................................................................. 579
Configuring Sub-Report Data Sources ..................................................... 580
Configuring Exporter Parameters ..................................................................... 580
22.12. Feed Views ................................................................................................. 581
22.13. JSON Mapping View .................................................................................... 581
22.14. XML Mapping View ...................................................................................... 582
23. Integrating with other web frameworks ....................................................................... 583
23.1. Introduction .................................................................................................... 583
23.2. Common configuration ................................................................................... 584
23.3. JavaServer Faces 1.2 .................................................................................... 585
SpringBeanFacesELResolver (JSF 1.2+) ......................................................... 585
FacesContextUtils ........................................................................................... 585
23.4. Apache Struts 2.x .......................................................................................... 585
23.5. Tapestry 5.x .................................................................................................. 586
23.6. Further Resources ......................................................................................... 586
24. Portlet MVC Framework ............................................................................................ 587
24.1. Introduction .................................................................................................... 587
Controllers - The C in MVC ............................................................................ 588
Views - The V in MVC .................................................................................... 588
Web-scoped beans ......................................................................................... 588
24.2. The DispatcherPortlet ..................................................................................... 588
24.3. The ViewRendererServlet ............................................................................... 590
24.4. Controllers ..................................................................................................... 591
AbstractController and PortletContentGenerator ............................................... 592
Other simple controllers .................................................................................. 593
Command Controllers ..................................................................................... 593
PortletWrappingController ................................................................................ 594
24.5. Handler mappings .......................................................................................... 594
PortletModeHandlerMapping ............................................................................ 595
ParameterHandlerMapping .............................................................................. 595
PortletModeParameterHandlerMapping ............................................................ 596
Adding HandlerInterceptors ............................................................................. 596
HandlerInterceptorAdapter ............................................................................... 597
ParameterMappingInterceptor .......................................................................... 597
24.6. Views and resolving them .............................................................................. 597
24.7. Multipart (file upload) support ......................................................................... 597
Using the PortletMultipartResolver ................................................................... 598
Spring Framework Reference Documentation
4.2.4.RELEASE Spring Framework xx
Handling a file upload in a form ...................................................................... 598
24.8. Handling exceptions ....................................................................................... 602
24.9. Annotation-based controller configuration ........................................................ 602
Setting up the dispatcher for annotation support ............................................... 602
Defining a controller with @Controller .............................................................. 603
Mapping requests with @RequestMapping ....................................................... 603
Supported handler method arguments ............................................................. 605
Binding request parameters to method parameters with @RequestParam .......... 607
Providing a link to data from the model with @ModelAttribute ............................ 607
Specifying attributes to store in a Session with @SessionAttributes .................... 608
Customizing WebDataBinder initialization ......................................................... 608
Customizing data binding with @InitBinder ............................................... 608
Configuring a custom WebBindingInitializer .............................................. 609
24.10. Portlet application deployment ...................................................................... 609
25. WebSocket Support .................................................................................................. 610
25.1. Introduction .................................................................................................... 610
WebSocket Fallback Options ........................................................................... 610
A Messaging Architecture ............................................................................... 611
Sub-Protocol Support in WebSocket ................................................................ 611
Should I Use WebSocket? .............................................................................. 611
25.2. WebSocket API ............................................................................................. 612
Create and Configure a WebSocketHandler ..................................................... 612
Customizing the WebSocket Handshake .......................................................... 613
WebSocketHandler Decoration ........................................................................ 614
Deployment Considerations ............................................................................. 614
Configuring the WebSocket Engine ................................................................. 615
Configuring allowed origins ............................................................................. 617
25.3. SockJS Fallback Options ................................................................................ 618
Overview of SockJS ....................................................................................... 618
Enable SockJS ............................................................................................... 619
HTTP Streaming in IE 8, 9: Ajax/XHR vs IFrame .............................................. 620
Heartbeat Messages ....................................................................................... 621
Servlet 3 Async Requests ............................................................................... 621
CORS Headers for SockJS ............................................................................. 622
SockJS Client ................................................................................................. 622
25.4. STOMP Over WebSocket Messaging Architecture ........................................... 624
Overview of STOMP ....................................................................................... 624
Enable STOMP over WebSocket ..................................................................... 625
Flow of Messages .......................................................................................... 627
Annotation Message Handling ......................................................................... 629
Sending Messages ......................................................................................... 631
Simple Broker ................................................................................................ 631
Full-Featured Broker ....................................................................................... 631
Connections To Full-Featured Broker .............................................................. 632
Using Dot as Separator in @MessageMapping Destinations .............................. 633
Authentication ................................................................................................. 634
User Destinations ........................................................................................... 635
Listening To ApplicationContext Events and Intercepting Messages ................... 636
STOMP Client ................................................................................................ 638
WebSocket Scope .......................................................................................... 639
剩余890页未读,继续阅读
点击了解资源详情
点击了解资源详情
点击了解资源详情
2017-08-22 上传
1278 浏览量
2019-01-09 上传
2020-08-31 上传
2020-06-21 上传
2019-06-04 上传
dluccoo
- 粉丝: 0
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功