没有合适的资源?快使用搜索试试~ 我知道了~
首页Spring 4.3.19官方文档:Spring框架参考教程
Spring 4.3.19官方文档:Spring框架参考教程
需积分: 9 1 下载量 3 浏览量
更新于2024-07-16
收藏 5.52MB PDF 举报
《Spring框架参考文档(4.3.19版)》是一份详尽的Spring Framework技术指南,由Spring社区的重要贡献者如Rod Johnson、Juergen Hoeller等编撰。该文档适用于4.3.19版本,涵盖了Spring Framework的核心概念、设计原则以及关键模块的详细介绍。
**1. 概览Spring框架**:
文档首先概述了Spring框架的总体理念,包括其在企业级应用开发中的地位和作用。Spring作为一款轻量级的IoC (Inversion of Control)和DI (Dependency Injection)容器,旨在简化Java应用程序的管理,提高代码的可测试性和可维护性。
**2. 开始使用Spring**:
这部分内容引导读者如何入门Spring,可能包括设置环境、配置基本的Spring应用上下文和bean定义,以及如何利用其依赖注入机制来管理和组织组件之间的关系。
**3. Spring框架基础**:
- **依赖注入和控制反转**:这是Spring的核心概念,它允许开发者将对对象的创建和管理职责移交给Spring容器,从而降低代码的耦合度和提高灵活性。
- **核心容器**:文档深入讲解了Spring容器的工作原理,包括BeanFactory和ApplicationContext接口,以及它们如何管理bean的生命周期和配置。
**4. AOP(面向切面编程)和Instrumentation**:
Spring支持AOP,帮助处理横切关注点,如事务管理、日志记录等,而Instrumentation部分可能涉及Spring对底层系统的监控和扩展能力。
**5. 框架模块详解**:
文档详细介绍了Spring Framework的各个模块,如核心模块、Web模块、数据访问/集成(JDBC、ORM)、消息传递(JMS、AMQP)、安全性(Spring Security)等,每个模块都包含了相应的配置和使用方法。
**版权与使用许可**:
文档强调了遵循的版权规则,允许个人复制和分发文档,但需确保不收取费用,并保留版权声明,无论是纸质还是电子形式传播。
这份Spring Framework Reference Documentation 4.3.19版提供了丰富的技术细节和实用指导,适合任何希望深入了解和使用Spring框架的开发者阅读,无论你是初学者还是经验丰富的开发者,都能从中获益良多。
Spring Framework Reference Documentation
4.3.19.RELEASE Spring Framework xvi
21.3. Using Marshaller and Unmarshaller ................................................................. 471
21.4. XML configuration namespace ........................................................................ 473
21.5. JAXB ............................................................................................................. 473
Jaxb2Marshaller ............................................................................................. 473
XML configuration namespace ................................................................ 474
21.6. Castor ........................................................................................................... 474
CastorMarshaller ............................................................................................ 474
Mapping ......................................................................................................... 475
XML configuration namespace ................................................................ 475
21.7. XMLBeans ..................................................................................................... 476
XmlBeansMarshaller ....................................................................................... 476
XML configuration namespace ................................................................ 476
21.8. JiBX .............................................................................................................. 476
JibxMarshaller ................................................................................................ 477
XML configuration namespace ................................................................ 477
21.9. XStream ........................................................................................................ 477
XStreamMarshaller ......................................................................................... 477
VI. The Web .......................................................................................................................... 479
22. Web MVC framework ................................................................................................ 480
22.1. Introduction to Spring Web MVC framework .................................................... 480
Features of Spring Web MVC ......................................................................... 480
Pluggability of other MVC implementations ...................................................... 482
22.2. The DispatcherServlet .................................................................................... 482
Special Bean Types In the WebApplicationContext ........................................... 486
Default DispatcherServlet Configuration ........................................................... 487
DispatcherServlet Processing Sequence .......................................................... 487
22.3. Implementing Controllers ................................................................................ 489
Defining a controller with @Controller .............................................................. 489
Mapping Requests With @RequestMapping ..................................................... 490
Composed @RequestMapping Variants ................................................... 491
@Controller and AOP Proxying ............................................................... 492
New Support Classes for @RequestMapping methods in Spring MVC 3.1 .. 492
URI Template Patterns ........................................................................... 493
URI Template Patterns with Regular Expressions ..................................... 494
Path Patterns ......................................................................................... 494
Path Pattern Comparison ........................................................................ 495
Path Patterns with Placeholders .............................................................. 495
Suffix Pattern Matching ........................................................................... 495
Suffix Pattern Matching and RFD ............................................................ 495
Matrix Variables ...................................................................................... 496
Consumable Media Types ....................................................................... 498
Producible Media Types .......................................................................... 498
Request Parameters and Header Values ................................................. 499
HTTP HEAD and HTTP OPTIONS .......................................................... 499
Defining @RequestMapping handler methods .................................................. 500
Supported method argument types .......................................................... 500
Supported method return types ............................................................... 502
Binding request parameters to method parameters with @RequestParam ... 503
Mapping the request body with the @RequestBody annotation .................. 504
Mapping the response body with the @ResponseBody annotation ............. 505
Spring Framework Reference Documentation
4.3.19.RELEASE Spring Framework xvii
Creating REST Controllers with the @RestController annotation ................ 506
Using HttpEntity ...................................................................................... 506
Using @ModelAttribute on a method ....................................................... 506
Using @ModelAttribute on a method argument ......................................... 507
Using @SessionAttributes to store model attributes in the HTTP session
between requests ................................................................................... 509
Using @SessionAttribute to access pre-existing global session attributes .... 510
Using @RequestAttribute to access request attributes .............................. 510
Working with "application/x-www-form-urlencoded" data ............................ 510
Mapping cookie values with the @CookieValue annotation ........................ 511
Mapping request header attributes with the @RequestHeader annotation ... 511
Method Parameters And Type Conversion ............................................... 512
Customizing WebDataBinder initialization ................................................. 512
Advising controllers with @ControllerAdvice and @RestControllerAdvice .... 513
Jackson Serialization View Support ......................................................... 514
Jackson JSONP Support ........................................................................ 515
Asynchronous Request Processing .................................................................. 516
Exception Handling for Async Requests ................................................... 517
Intercepting Async Requests ................................................................... 518
HTTP Streaming ..................................................................................... 518
HTTP Streaming With Server-Sent Events ............................................... 518
HTTP Streaming Directly To The OutputStream ....................................... 519
Configuring Asynchronous Request Processing ........................................ 519
Testing Controllers ......................................................................................... 520
22.4. Handler mappings .......................................................................................... 520
Intercepting requests with a HandlerInterceptor ................................................ 521
22.5. Resolving views ............................................................................................. 523
Resolving views with the ViewResolver interface .............................................. 523
Chaining ViewResolvers ................................................................................. 525
Redirecting to Views ....................................................................................... 525
RedirectView .......................................................................................... 526
The redirect: prefix ................................................................................. 527
The forward: prefix ................................................................................. 527
ContentNegotiatingViewResolver ..................................................................... 527
22.6. Using flash attributes ..................................................................................... 529
22.7. Building URIs ................................................................................................. 530
Building URIs to Controllers and methods ........................................................ 531
Working with "Forwarded" and "X-Forwarded-*" Headers .................................. 532
Building URIs to Controllers and methods from views ....................................... 532
22.8. Using locales ................................................................................................. 533
Obtaining Time Zone Information .................................................................... 534
AcceptHeaderLocaleResolver .......................................................................... 534
CookieLocaleResolver ..................................................................................... 534
SessionLocaleResolver ................................................................................... 534
LocaleChangeInterceptor ................................................................................ 535
22.9. Using themes ................................................................................................ 535
Overview of themes ........................................................................................ 535
Defining themes ............................................................................................. 535
Theme resolvers ............................................................................................. 536
22.10. Spring’s multipart (file upload) support ........................................................... 536
Spring Framework Reference Documentation
4.3.19.RELEASE Spring Framework xviii
Introduction .................................................................................................... 536
Using a MultipartResolver with Commons FileUpload ........................................ 537
Using a MultipartResolver with Servlet 3.0 ....................................................... 537
Handling a file upload in a form ...................................................................... 537
Handling a file upload request from programmatic clients .................................. 538
22.11. Handling exceptions ..................................................................................... 539
HandlerExceptionResolver .............................................................................. 539
@ExceptionHandler ........................................................................................ 540
Handling Standard Spring MVC Exceptions ...................................................... 541
Annotating Business Exceptions With @ResponseStatus .................................. 542
Customizing the Default Servlet Container Error Page ...................................... 542
22.12. Web Security ............................................................................................... 543
22.13. Convention over configuration support ........................................................... 543
The Controller ControllerClassNameHandlerMapping ........................................ 543
The Model ModelMap (ModelAndView) ............................................................ 544
Default view name .......................................................................................... 545
22.14. HTTP caching support .................................................................................. 547
Cache-Control HTTP header ........................................................................... 547
HTTP caching support for static resources ....................................................... 547
Support for the Cache-Control, ETag and Last-Modified response headers in
Controllers ...................................................................................................... 548
Shallow ETag support ..................................................................................... 549
22.15. Code-based Servlet container initialization ..................................................... 550
22.16. Configuring Spring MVC ............................................................................... 552
Enabling the MVC Java Config or the MVC XML Namespace ............................ 552
Customizing the Provided Configuration ........................................................... 554
Conversion and Formatting ............................................................................. 554
Validation ....................................................................................................... 555
Interceptors .................................................................................................... 556
Content Negotiation ........................................................................................ 557
View Controllers ............................................................................................. 558
View Resolvers .............................................................................................. 558
Serving of Resources ..................................................................................... 559
Default Servlet ................................................................................................ 562
Path Matching ................................................................................................ 563
Message Converters ....................................................................................... 563
Advanced Customizations with MVC Java Config ............................................. 564
Advanced Customizations with the MVC Namespace ........................................ 565
23. View Technologies .................................................................................................... 566
23.1. Introduction .................................................................................................... 566
23.2. Thymeleaf ..................................................................................................... 566
23.3. Groovy Markup .............................................................................................. 566
Configuration .................................................................................................. 566
Example ......................................................................................................... 567
23.4. Velocity & FreeMarker .................................................................................... 567
Dependencies ................................................................................................ 567
Context configuration ...................................................................................... 567
Creating templates ......................................................................................... 568
Advanced configuration ................................................................................... 568
velocity.properties ................................................................................... 568
Spring Framework Reference Documentation
4.3.19.RELEASE Spring Framework xix
FreeMarker ............................................................................................. 569
Bind support and form handling ....................................................................... 569
The bind macros .................................................................................... 569
Simple binding ........................................................................................ 570
Form input generation macros ................................................................. 570
HTML escaping and XHTML compliance ................................................. 574
23.5. JSP & JSTL .................................................................................................. 574
View resolvers ................................................................................................ 575
'Plain-old' JSPs versus JSTL ........................................................................... 575
Spring’s JSP tag library .................................................................................. 575
Spring’s form tag library .................................................................................. 575
Configuration .......................................................................................... 576
The form tag .......................................................................................... 576
The input tag .......................................................................................... 577
The checkbox tag ................................................................................... 577
The checkboxes tag ............................................................................... 579
The radiobutton tag ................................................................................ 580
The radiobuttons tag ............................................................................... 580
The password tag ................................................................................... 580
The select tag ........................................................................................ 580
The option tag ........................................................................................ 581
The options tag ...................................................................................... 581
The textarea tag ..................................................................................... 582
The hidden tag ....................................................................................... 582
The errors tag ........................................................................................ 582
HTTP method conversion ........................................................................ 584
HTML5 tags ........................................................................................... 585
23.6. Script views ................................................................................................... 585
Requirements ................................................................................................. 586
Script templates .............................................................................................. 586
23.7. XML Marshalling ............................................................................................ 588
23.8. Tiles .............................................................................................................. 588
Dependencies ................................................................................................ 588
Configuration .................................................................................................. 588
UrlBasedViewResolver ............................................................................ 589
ResourceBundleViewResolver ................................................................. 589
SimpleSpringPreparerFactory and SpringBeanPreparerFactory ................. 590
23.9. XSLT ............................................................................................................. 590
Beans ............................................................................................................ 591
Controller ....................................................................................................... 591
Transformation ............................................................................................... 592
23.10. Document views: PDF, Excel ........................................................................ 592
Introduction .................................................................................................... 592
Configuration .................................................................................................. 593
View definition ................................................................................................ 593
Controller ....................................................................................................... 593
Excel views .................................................................................................... 593
PDF views ..................................................................................................... 595
23.11. JasperReports .............................................................................................. 595
Dependencies ................................................................................................ 595
Spring Framework Reference Documentation
4.3.19.RELEASE Spring Framework xx
Configuration .................................................................................................. 595
Configuring the ViewResolver .................................................................. 596
Configuring the Views ............................................................................. 596
About Report Files .................................................................................. 596
Using JasperReportsMultiFormatView ...................................................... 596
Populating the ModelAndView ......................................................................... 597
Working with sub-reports ................................................................................ 598
Configuring sub-report files ..................................................................... 598
Configuring sub-report data sources ........................................................ 599
Configuring exporter parameters ..................................................................... 599
23.12. Feed views: RSS, Atom ............................................................................... 600
23.13. JSON Mapping View .................................................................................... 600
23.14. XML Mapping View ...................................................................................... 601
24. Integrating with other web frameworks ....................................................................... 602
24.1. Introduction .................................................................................................... 602
24.2. Common configuration ................................................................................... 603
24.3. JavaServer Faces 1.2 .................................................................................... 604
SpringBeanFacesELResolver (JSF 1.2+) ......................................................... 604
FacesContextUtils ........................................................................................... 604
24.4. Apache Struts 2.x .......................................................................................... 604
24.5. Tapestry 5.x .................................................................................................. 605
24.6. Further Resources ......................................................................................... 605
25. Portlet MVC Framework ............................................................................................ 606
25.1. Introduction .................................................................................................... 606
Controllers - The C in MVC ............................................................................ 607
Views - The V in MVC .................................................................................... 607
Web-scoped beans ......................................................................................... 607
25.2. The DispatcherPortlet ..................................................................................... 607
25.3. The ViewRendererServlet ............................................................................... 609
25.4. Controllers ..................................................................................................... 610
AbstractController and PortletContentGenerator ............................................... 611
Other simple controllers .................................................................................. 612
Command Controllers ..................................................................................... 612
PortletWrappingController ................................................................................ 613
25.5. Handler mappings .......................................................................................... 613
PortletModeHandlerMapping ............................................................................ 614
ParameterHandlerMapping .............................................................................. 614
PortletModeParameterHandlerMapping ............................................................ 615
Adding HandlerInterceptors ............................................................................. 615
HandlerInterceptorAdapter ............................................................................... 616
ParameterMappingInterceptor .......................................................................... 616
25.6. Views and resolving them .............................................................................. 616
25.7. Multipart (file upload) support ......................................................................... 616
Using the PortletMultipartResolver ................................................................... 617
Handling a file upload in a form ...................................................................... 617
25.8. Handling exceptions ....................................................................................... 621
25.9. Annotation-based controller configuration ........................................................ 621
Setting up the dispatcher for annotation support ............................................... 621
Defining a controller with @Controller .............................................................. 622
Mapping requests with @RequestMapping ....................................................... 622
剩余915页未读,继续阅读
188 浏览量
217 浏览量
136 浏览量
195 浏览量
110 浏览量
150 浏览量
211 浏览量
2024-04-21 上传
追风地少年
- 粉丝: 39
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 高仿百思不得姐demo.zip
- 住宅楼户型设计CAD参考图纸图集(13)
- Java高效排序算法前五位
- 拖动滑块选择数字插件sider.jquery.js
- ClinicManagementSystem:为胸部诊所Borella开发基于Web的信息和管理系统。 提供改善胸部诊所信息收集和管理任务的方法
- 监控别人的行踪
- 互联网
- KeyListPerf.zip
- 网络商城B2C项目商业计划书
- rails_learnings
- 3D 曲线:本书第 7 章中描述的 3D 曲线示例:“CRC 标准曲线和曲面”-matlab开发
- Report-It-Android-Advanced:报告这是一个应用程序,允许其用户报告从垃圾到涂鸦和坑洼的各种问题。 该应用代表了Android高级课程的最终项目(面向程序员的Google Digital Workshop)
- Lojinha-de-lanche:Curso教授Macoratti
- 简单的论坛系统.zip
- awesome-joplin:Jo精选的乔普林主题和工具清单
- CAD墙面浮雕图块装饰素材1(11款)
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功