Spring Framework Reference Documentation

Authors

Rod Johnson , Juergen Hoeller , Keith Donald , Colin Sampaleanu , Rob Harrop , Thomas Risberg , Alef Arendsen , Darren Davison , Dmitriy Kopylenko , Mark Pollack , Thierry Templier , Erwin Vervaet , Portia Tung , Ben Hale , Adrian Colyer , John Lewis , Costin Leau , Mark Fisher , Sam Brannen , Ramnivas Laddad , Arjen Poutsma , Chris Beams , Tareq Abedrabbo , Andy Clement , Dave Syer , Oliver Gierke , Rossen Stoyanchev , Phillip Webb , Rob Winch , Brian Clozel , Stephane Nicoll , Sebastien Deleuze

4.0.3.RELEASE

Copies of this document may be made for your own use and for distribution to others, provided that you do not charge any fee for such copies and further provided that each copy contains this Copyright Notice, whether distributed in print or electronically.


Table of Contents

I. Overview of Spring Framework
1. Getting Started With Spring
2. Introduction to Spring Framework
2.1. Dependency Injection and Inversion of Control
2.2. Modules
2.2.1. Core Container
2.2.2. Data Access/Integration
2.2.3. Web
2.2.4. AOP and Instrumentation
2.2.5. Test
2.3. Usage scenarios
2.3.1. Dependency Management and Naming Conventions
Spring Dependencies and Depending on Spring
Maven Dependency Management
Maven "Bill Of Materials" Dependency
Gradle Dependency Management
Ivy Dependency Management
Distribution Zip Files
2.3.2. Logging
Not Using Commons Logging
Using SLF4J
Using Log4J
II. What’s New in Spring Framework 4.x
3. New Features and Enhancements in Spring Framework 4.0
3.1. Improved Getting Started Experience
3.2. Removed Deprecated Packages and Methods
3.3. Java 8 (as well as 6 and 7)
3.4. Java EE 6 and 7
3.5. Groovy Bean Definition DSL
3.6. Core Container Improvements
3.7. General Web Improvements
3.8. WebSocket, SockJS, and STOMP Messaging
3.9. Testing Improvements
III. Core Technologies
4. The IoC container
4.1. Introduction to the Spring IoC container and beans
4.2. Container overview
4.2.1. Configuration metadata
4.2.2. Instantiating a container
Composing XML-based configuration metadata
4.2.3. Using the container
4.3. Bean overview
4.3.1. Naming beans
Aliasing a bean outside the bean definition
4.3.2. Instantiating beans
Instantiation with a constructor
Instantiation with a static factory method
Instantiation using an instance factory method
4.4. Dependencies
4.4.1. Dependency injection
Constructor-based dependency injection
Setter-based dependency injection
Dependency resolution process
Examples of dependency injection
4.4.2. Dependencies and configuration in detail
Straight values (primitives, Strings, and so on)
References to other beans (collaborators)
Inner beans
Collections
Null and empty string values
XML shortcut with the p-namespace
XML shortcut with the c-namespace
Compound property names
4.4.3. Using depends-on
4.4.4. Lazy-initialized beans
4.4.5. Autowiring collaborators
Limitations and disadvantages of autowiring
Excluding a bean from autowiring
4.4.6. Method injection
Lookup method injection
Arbitrary method replacement
4.5. Bean scopes
4.5.1. The singleton scope
4.5.2. The prototype scope
4.5.3. Singleton beans with prototype-bean dependencies
4.5.4. Request, session, and global session scopes
Initial web configuration
Request scope
Session scope
Global session scope
Scoped beans as dependencies
4.5.5. Custom scopes
Creating a custom scope
Using a custom scope
4.6. Customizing the nature of a bean
4.6.1. Lifecycle callbacks
Initialization callbacks
Destruction callbacks
Default initialization and destroy methods
Combining lifecycle mechanisms
Startup and shutdown callbacks
Shutting down the Spring IoC container gracefully in non-web applications
4.6.2. ApplicationContextAware and BeanNameAware
4.6.3. Other Aware interfaces
4.7. Bean definition inheritance
4.8. Container Extension Points
4.8.1. Customizing beans using a BeanPostProcessor
Example: Hello World, BeanPostProcessor-style
Example: The RequiredAnnotationBeanPostProcessor
4.8.2. Customizing configuration metadata with a BeanFactoryPostProcessor
Example: the Class name substitution PropertyPlaceholderConfigurer
Example: the PropertyOverrideConfigurer
4.8.3. Customizing instantiation logic with a FactoryBean
4.9. Annotation-based container configuration
4.9.1. @Required
4.9.2. @Autowired
4.9.3. Fine-tuning annotation-based autowiring with qualifiers
4.9.4. Using generics as autowiring qualifiers
4.9.5. CustomAutowireConfigurer
4.9.6. @Resource
4.9.7. @PostConstruct and @PreDestroy
4.10. Classpath scanning and managed components
4.10.1. @Component and further stereotype annotations
4.10.2. Meta-annotations
4.10.3. Automatically detecting classes and registering bean definitions
4.10.4. Using filters to customize scanning
4.10.5. Defining bean metadata within components
4.10.6. Naming autodetected components
4.10.7. Providing a scope for autodetected components
4.10.8. Providing qualifier metadata with annotations
4.11. Using JSR 330 Standard Annotations
4.11.1. Dependency Injection with @Inject and @Named
4.11.2. @Named: a standard equivalent to the @Component annotation
4.11.3. Limitations of the standard approach
4.12. Java-based container configuration
4.12.1. Basic concepts: @Bean and @Configuration
4.12.2. Instantiating the Spring container using AnnotationConfigApplicationContext
Simple construction
Building the container programmatically using register(Class<?>…)
Enabling component scanning with scan(String…)
Support for web applications with AnnotationConfigWebApplicationContext
4.12.3. Using the @Bean annotation
Declaring a bean
Receiving lifecycle callbacks
Specifying bean scope
Customizing bean naming
Bean aliasing
Bean description
4.12.4. Using the @Configuration annotation
Injecting inter-bean dependencies
Lookup method injection
Further information about how Java-based configuration works internally
4.12.5. Composing Java-based configurations
Using the @Import annotation
Conditionally including @Configuration classes or @Beans
Combining Java and XML configuration
4.13. Bean definition profiles and environment abstraction
4.14. PropertySource Abstraction
4.15. Registering a LoadTimeWeaver
4.16. Additional Capabilities of the ApplicationContext
4.16.1. Internationalization using MessageSource
4.16.2. Standard and Custom Events
4.16.3. Convenient access to low-level resources
4.16.4. Convenient ApplicationContext instantiation for web applications
4.16.5. Deploying a Spring ApplicationContext as a J2EE RAR file
4.17. The BeanFactory
4.17.1. BeanFactory or ApplicationContext?
4.17.2. Glue code and the evil singleton
5. Resources
5.1. Introduction
5.2. The Resource interface
5.3. Built-in Resource implementations
5.3.1. UrlResource
5.3.2. ClassPathResource
5.3.3. FileSystemResource
5.3.4. ServletContextResource
5.3.5. InputStreamResource
5.3.6. ByteArrayResource
5.4. The ResourceLoader
5.5. The ResourceLoaderAware interface
5.6. Resources as dependencies
5.7. Application contexts and Resource paths
5.7.1. Constructing application contexts
Constructing ClassPathXmlApplicationContext instances - shortcuts
5.7.2. Wildcards in application context constructor resource paths
Ant-style Patterns
The Classpath*: portability classpath*: prefix
Other notes relating to wildcards
5.7.3. FileSystemResource caveats
6. Validation, Data Binding, and Type Conversion
6.1. Introduction
6.2. Validation using Spring’s Validator interface
6.3. Resolving codes to error messages
6.4. Bean manipulation and the BeanWrapper
6.4.1. Setting and getting basic and nested properties
6.4.2. Built-in PropertyEditor implementations
Registering additional custom PropertyEditors
6.5. Spring Type Conversion
6.5.1. Converter SPI
6.5.2. ConverterFactory
6.5.3. GenericConverter
ConditionalGenericConverter
6.5.4. ConversionService API
6.5.5. Configuring a ConversionService
6.5.6. Using a ConversionService programmatically
6.6. Spring Field Formatting
6.6.1. Formatter SPI
6.6.2. Annotation-driven Formatting
Format Annotation API
6.6.3. FormatterRegistry SPI
6.6.4. FormatterRegistrar SPI
6.6.5. Configuring Formatting in Spring MVC
6.7. Configuring a global date & time format
6.8. Spring Validation
6.8.1. Overview of the JSR-303 Bean Validation API
6.8.2. Configuring a Bean Validation Provider
Injecting a Validator
Configuring Custom Constraints
Spring-driven Method Validation
Additional Configuration Options
6.8.3. Configuring a DataBinder
6.8.4. Spring MVC 3 Validation
Triggering @Controller Input Validation
Configuring a Validator for use by Spring MVC
Configuring a JSR-303/JSR-349 Validator for use by Spring MVC
7. Spring Expression Language (SpEL)
7.1. Introduction
7.2. Feature Overview
7.3. Expression Evaluation using Spring’s Expression Interface
7.3.1. The EvaluationContext interface
Type Conversion
7.4. Expression support for defining bean definitions
7.4.1. XML based configuration
7.4.2. Annotation-based configuration
7.5. Language Reference
7.5.1. Literal expressions
7.5.2. Properties, Arrays, Lists, Maps, Indexers
7.5.3. Inline lists
7.5.4. Array construction
7.5.5. Methods
7.5.6. Operators
Relational operators
Logical operators
Mathematical operators
7.5.7. Assignment
7.5.8. Types
7.5.9. Constructors
7.5.10. Variables
The #this and #root variables
7.5.11. Functions
7.5.12. Bean references
7.5.13. Ternary Operator (If-Then-Else)
7.5.14. The Elvis Operator
7.5.15. Safe Navigation operator
7.5.16. Collection Selection
7.5.17. Collection Projection
7.5.18. Expression templating
7.6. Classes used in the examples
8. Aspect Oriented Programming with Spring
8.1. Introduction
8.1.1. AOP concepts
8.1.2. Spring AOP capabilities and goals
8.1.3. AOP Proxies
8.2. @AspectJ support
8.2.1. Enabling @AspectJ Support
Enabling @AspectJ Support with Java configuration
Enabling @AspectJ Support with XML configuration
8.2.2. Declaring an aspect
8.2.3. Declaring a pointcut
Supported Pointcut Designators
Combining pointcut expressions
Sharing common pointcut definitions
Examples
Writing good pointcuts
8.2.4. Declaring advice
Before advice
After returning advice
After throwing advice
After (finally) advice
Around advice
Advice parameters
Advice ordering
8.2.5. Introductions
8.2.6. Aspect instantiation models
8.2.7. Example
8.3. Schema-based AOP support
8.3.1. Declaring an aspect
8.3.2. Declaring a pointcut
8.3.3. Declaring advice
Before advice
After returning advice
After throwing advice
After (finally) advice
Around advice
Advice parameters
Advice ordering
8.3.4. Introductions
8.3.5. Aspect instantiation models
8.3.6. Advisors
8.3.7. Example
8.4. Choosing which AOP declaration style to use
8.4.1. Spring AOP or full AspectJ?
8.4.2. @AspectJ or XML for Spring AOP?
8.5. Mixing aspect types
8.6. Proxying mechanisms
8.6.1. Understanding AOP proxies
8.7. Programmatic creation of @AspectJ Proxies
8.8. Using AspectJ with Spring applications
8.8.1. Using AspectJ to dependency inject domain objects with Spring
Unit testing @Configurable objects
Working with multiple application contexts
8.8.2. Other Spring aspects for AspectJ
8.8.3. Configuring AspectJ aspects using Spring IoC
8.8.4. Load-time weaving with AspectJ in the Spring Framework
A first example
Aspects
' META-INF/aop.xml'
Required libraries (JARS)
Spring configuration
Environment-specific configuration
8.9. Further Resources
9. Spring AOP APIs
9.1. Introduction
9.2. Pointcut API in Spring
9.2.1. Concepts
9.2.2. Operations on pointcuts
9.2.3. AspectJ expression pointcuts
9.2.4. Convenience pointcut implementations
Static pointcuts
Dynamic pointcuts
9.2.5. Pointcut superclasses
9.2.6. Custom pointcuts
9.3. Advice API in Spring
9.3.1. Advice lifecycles
9.3.2. Advice types in Spring
Interception around advice
Before advice
Throws advice
After Returning advice
Introduction advice
9.4. Advisor API in Spring
9.5. Using the ProxyFactoryBean to create AOP proxies
9.5.1. Basics
9.5.2. JavaBean properties
9.5.3. JDK- and CGLIB-based proxies
9.5.4. Proxying interfaces
9.5.5. Proxying classes
9.5.6. Using global advisors
9.6. Concise proxy definitions
9.7. Creating AOP proxies programmatically with the ProxyFactory
9.8. Manipulating advised objects
9.9. Using the "auto-proxy" facility
9.9.1. Autoproxy bean definitions
BeanNameAutoProxyCreator
DefaultAdvisorAutoProxyCreator
AbstractAdvisorAutoProxyCreator
9.9.2. Using metadata-driven auto-proxying
9.10. Using TargetSources
9.10.1. Hot swappable target sources
9.10.2. Pooling target sources
9.10.3. Prototype target sources
9.10.4. ThreadLocal target sources
9.11. Defining new Advice types
9.12. Further resources
10. Testing
10.1. Introduction to Spring Testing
10.2. Unit Testing
10.2.1. Mock Objects
Environment
JNDI
Servlet API
Portlet API
10.2.2. Unit Testing support Classes
General utilities
Spring MVC
10.3. Integration Testing
10.3.1. Overview
10.3.2. Goals of Integration Testing
Context management and caching
Dependency Injection of test fixtures
Transaction management
Support classes for integration testing
10.3.3. JDBC Testing Support
10.3.4. Annotations
Spring Testing Annotations
Standard Annotation Support
Spring JUnit Testing Annotations
Meta-Annotation Support for Testing
10.3.5. Spring TestContext Framework
Key abstractions
Context management
Dependency injection of test fixtures
Testing request and session scoped beans
Transaction management
TestContext Framework support classes
10.3.6. Spring MVC Test Framework
Server-Side Tests
Client-Side REST Tests
10.3.7. PetClinic Example
10.4. Further Resources
IV. Data Access
11. Transaction Management
11.1. Introduction to Spring Framework transaction management
11.2. Advantages of the Spring Framework’s transaction support model
11.2.1. Global transactions
11.2.2. Local transactions
11.2.3. Spring Framework’s consistent programming model
11.3. Understanding the Spring Framework transaction abstraction
11.4. Synchronizing resources with transactions
11.4.1. High-level synchronization approach
11.4.2. Low-level synchronization approach
11.4.3. TransactionAwareDataSourceProxy
11.5. Declarative transaction management
11.5.1. Understanding the Spring Framework’s declarative transaction implementation
11.5.2. Example of declarative transaction implementation
11.5.3. Rolling back a declarative transaction
11.5.4. Configuring different transactional semantics for different beans
11.5.5. <tx:advice/> settings
11.5.6. Using @Transactional
@Transactional settings
Multiple Transaction Managers with @Transactional
Custom shortcut annotations
11.5.7. Transaction propagation
Required
RequiresNew
Nested
11.5.8. Advising transactional operations
11.5.9. Using @Transactional with AspectJ
11.6. Programmatic transaction management
11.6.1. Using the TransactionTemplate
Specifying transaction settings
11.6.2. Using the PlatformTransactionManager
11.7. Choosing between programmatic and declarative transaction management
11.8. Application server-specific integration
11.8.1. IBM WebSphere
11.8.2. Oracle WebLogic Server
11.9. Solutions to common problems
11.9.1. Use of the wrong transaction manager for a specific DataSource
11.10. Further Resources
12. DAO support
12.1. Introduction
12.2. Consistent exception hierarchy
12.3. Annotations used for configuring DAO or Repository classes
13. Data access with JDBC
13.1. Introduction to Spring Framework JDBC
13.1.1. Choosing an approach for JDBC database access
13.1.2. Package hierarchy
13.2. Using the JDBC core classes to control basic JDBC processing and error handling
13.2.1. JdbcTemplate
Examples of JdbcTemplate class usage
JdbcTemplate best practices
13.2.2. NamedParameterJdbcTemplate
13.2.3. SQLExceptionTranslator
13.2.4. Executing statements
13.2.5. Running queries
13.2.6. Updating the database
13.2.7. Retrieving auto-generated keys
13.3. Controlling database connections
13.3.1. DataSource
13.3.2. DataSourceUtils
13.3.3. SmartDataSource
13.3.4. AbstractDataSource
13.3.5. SingleConnectionDataSource
13.3.6. DriverManagerDataSource
13.3.7. TransactionAwareDataSourceProxy
13.3.8. DataSourceTransactionManager
13.3.9. NativeJdbcExtractor
13.4. JDBC batch operations
13.4.1. Basic batch operations with the JdbcTemplate
13.4.2. Batch operations with a List of objects
13.4.3. Batch operations with multiple batches
13.5. Simplifying JDBC operations with the SimpleJdbc classes
13.5.1. Inserting data using SimpleJdbcInsert
13.5.2. Retrieving auto-generated keys using SimpleJdbcInsert
13.5.3. Specifying columns for a SimpleJdbcInsert
13.5.4. Using SqlParameterSource to provide parameter values
13.5.5. Calling a stored procedure with SimpleJdbcCall
13.5.6. Explicitly declaring parameters to use for a SimpleJdbcCall
13.5.7. How to define SqlParameters
13.5.8. Calling a stored function using SimpleJdbcCall
13.5.9. Returning ResultSet/REF Cursor from a SimpleJdbcCall
13.6. Modeling JDBC operations as Java objects
13.6.1. SqlQuery
13.6.2. MappingSqlQuery
13.6.3. SqlUpdate
13.6.4. StoredProcedure
13.7. Common problems with parameter and data value handling
13.7.1. Providing SQL type information for parameters
13.7.2. Handling BLOB and CLOB objects
13.7.3. Passing in lists of values for IN clause
13.7.4. Handling complex types for stored procedure calls
13.8. Embedded database support
13.8.1. Why use an embedded database?
13.8.2. Creating an embedded database instance using Spring XML
13.8.3. Creating an embedded database instance programmatically
13.8.4. Extending the embedded database support
13.8.5. Using HSQL
13.8.6. Using H2
13.8.7. Using Derby
13.8.8. Testing data access logic with an embedded database
13.9. Initializing a DataSource
13.9.1. Initializing a database instance using Spring XML
Initialization of Other Components that Depend on the Database
14. Object Relational Mapping (ORM) Data Access
14.1. Introduction to ORM with Spring
14.2. General ORM integration considerations
14.2.1. Resource and transaction management
14.2.2. Exception translation
14.3. Hibernate
14.3.1. SessionFactory setup in a Spring container
14.3.2. Implementing DAOs based on plain Hibernate 3 API
14.3.3. Declarative transaction demarcation
14.3.4. Programmatic transaction demarcation
14.3.5. Transaction management strategies
14.3.6. Comparing container-managed and locally defined resources
14.3.7. Spurious application server warnings with Hibernate
14.4. JDO
14.4.1. PersistenceManagerFactory setup
14.4.2. Implementing DAOs based on the plain JDO API
14.4.3. Transaction management
14.4.4. JdoDialect
14.5. JPA
14.5.1. Three options for JPA setup in a Spring environment
LocalEntityManagerFactoryBean
Obtaining an EntityManagerFactory from JNDI
LocalContainerEntityManagerFactoryBean
Dealing with multiple persistence units
14.5.2. Implementing DAOs based on plain JPA
14.5.3. Transaction Management
14.5.4. JpaDialect
15. Marshalling XML using O/X Mappers
15.1. Introduction
15.1.1. Ease of configuration
15.1.2. Consistent Interfaces
15.1.3. Consistent Exception Hierarchy
15.2. Marshaller and Unmarshaller
15.2.1. Marshaller
15.2.2. Unmarshaller
15.2.3. XmlMappingException
15.3. Using Marshaller and Unmarshaller
15.4. XML Schema-based Configuration
15.5. JAXB
15.5.1. Jaxb2Marshaller
XML Schema-based Configuration
15.6. Castor
15.6.1. CastorMarshaller
15.6.2. Mapping
XML Schema-based Configuration
15.7. XMLBeans
15.7.1. XmlBeansMarshaller
XML Schema-based Configuration
15.8. JiBX
15.8.1. JibxMarshaller
XML Schema-based Configuration
15.9. XStream
15.9.1. XStreamMarshaller
V. The Web
16. Web MVC framework
16.1. Introduction to Spring Web MVC framework
16.1.1. Features of Spring Web MVC
16.1.2. Pluggability of other MVC implementations
16.2. The DispatcherServlet
16.2.1. Special Bean Types In the WebApplicationContext
16.2.2. Default DispatcherServlet Configuration
16.2.3. DispatcherServlet Processing Sequence
16.3. Implementing Controllers
16.3.1. Defining a controller with @Controller
16.3.2. Mapping Requests With @RequestMapping
@Controller's and AOP Proxying
New Support Classes for @RequestMapping methods in Spring MVC 3.1
URI Template Patterns
URI Template Patterns with Regular Expressions
Path Patterns
Patterns with Placeholders
Matrix Variables
Consumable Media Types
Producible Media Types
Request Parameters and Header Values
16.3.3. Defining @RequestMapping handler methods
Supported method argument types
Supported method return types
Binding request parameters to method parameters with @RequestParam
Mapping the request body with the @RequestBody annotation
Mapping the response body with the @ResponseBody annotation
Creating REST Controllers with the @RestController annotation
Using HttpEntity
Using @ModelAttribute on a method
Using @ModelAttribute on a method argument
Using @SessionAttributes to store model attributes in the HTTP session between requests
Specifying redirect and flash attributes
Working with "application/x-www-form-urlencoded" data
Mapping cookie values with the @CookieValue annotation
Mapping request header attributes with the @RequestHeader annotation
Method Parameters And Type Conversion
Customizing WebDataBinder initialization
Support for the Last-Modified Response Header To Facilitate Content Caching
Assisting Controllers with the @ControllerAdvice annotation
16.3.4. Asynchronous Request Processing
Exception Handling for Async Requests
Intercepting Async Requests
Configuration for Async Request Processing
16.3.5. Testing Controllers
16.4. Handler mappings
16.4.1. Intercepting requests with a HandlerInterceptor
16.5. Resolving views
16.5.1. Resolving views with the ViewResolver interface
16.5.2. Chaining ViewResolvers
16.5.3. Redirecting to views
RedirectView
The redirect: prefix
The forward: prefix
16.5.4. ContentNegotiatingViewResolver
16.6. Using flash attributes
16.7. Building URIs
16.8. Building URIs to Controllers and methods
16.9. Using locales
16.9.1. Obtaining Time Zone Information
16.9.2. AcceptHeaderLocaleResolver
16.9.3. CookieLocaleResolver
16.9.4. SessionLocaleResolver
16.9.5. LocaleChangeInterceptor
16.10. Using themes
16.10.1. Overview of themes
16.10.2. Defining themes
16.10.3. Theme resolvers
16.11. Spring’s multipart (file upload) support
16.11.1. Introduction
16.11.2. Using a MultipartResolver with Commons FileUpload
16.11.3. Using a MultipartResolver with Servlet 3.0
16.11.4. Handling a file upload in a form
16.11.5. Handling a file upload request from programmatic clients
16.12. Handling exceptions
16.12.1. HandlerExceptionResolver
16.12.2. @ExceptionHandler
16.12.3. Handling Standard Spring MVC Exceptions
16.12.4. Annotating Business Exceptions With @ResponseStatus
16.12.5. Customizing the Default Servlet Container Error Page
16.13. Convention over configuration support
16.13.1. The Controller ControllerClassNameHandlerMapping
16.13.2. The Model ModelMap (ModelAndView)
16.13.3. The View - RequestToViewNameTranslator
16.14. ETag support
16.15. Code-based Servlet container initialization
16.16. Configuring Spring MVC
16.16.1. Enabling the MVC Java Config or the MVC XML Namespace
16.16.2. Customizing the Provided Configuration
16.16.3. Configuring Interceptors
16.16.4. Configuring Content Negotiation
16.16.5. Configuring View Controllers
16.16.6. Configuring Serving of Resources
16.16.7. Configuring Path Matching
16.16.8. mvc:default-servlet-handler
16.16.9. More Spring Web MVC Resources
16.16.10. Advanced Customizations with MVC Java Config
16.16.11. Advanced Customizations with the MVC Namespace
17. View technologies
17.1. Introduction
17.2. JSP & JSTL
17.2.1. View resolvers
17.2.2. Plain-old JSPs versus JSTL
17.2.3. Additional tags facilitating development
17.2.4. Using Spring’s form tag library
Configuration
The form tag
The input tag
The checkbox tag
The checkboxes tag
The radiobutton tag
The radiobuttons tag
The password tag
The select tag
The option tag
The options tag
The textarea tag
The hidden tag
The errors tag
HTTP Method Conversion
HTML5 Tags
17.3. Tiles
17.3.1. Dependencies
17.3.2. How to integrate Tiles
UrlBasedViewResolver
ResourceBundleViewResolver
SimpleSpringPreparerFactory and SpringBeanPreparerFactory
17.4. Velocity & FreeMarker
17.4.1. Dependencies
17.4.2. Context configuration
17.4.3. Creating templates
17.4.4. Advanced configuration
velocity.properties
FreeMarker
17.4.5. Bind support and form handling
The bind macros
Simple binding
Form input generation macros
HTML escaping and XHTML compliance
17.5. XSLT
17.5.1. My First Words
Bean definitions
Standard MVC controller code
Convert the model data to XML
Defining the view properties
Document transformation
17.5.2. Summary
17.6. Document views (PDF/Excel)
17.6.1. Introduction
17.6.2. Configuration and setup
Document view definitions
Controller code
Subclassing for Excel views
Subclassing for PDF views
17.7. JasperReports
17.7.1. Dependencies
17.7.2. Configuration
Configuring the ViewResolver
Configuring the Views
About Report Files
Using JasperReportsMultiFormatView
17.7.3. Populating the ModelAndView
17.7.4. Working with Sub-Reports
Configuring Sub-Report Files
Configuring Sub-Report Data Sources
17.7.5. Configuring Exporter Parameters
17.8. Feed Views
17.9. XML Marshalling View
17.10. JSON Mapping View
18. Integrating with other web frameworks
18.1. Introduction
18.2. Common configuration
18.3. JavaServer Faces 1.2
18.3.1. SpringBeanFacesELResolver (JSF 1.2+)
18.3.2. FacesContextUtils
18.4. Apache Struts 2.x
18.5. Tapestry 5.x
18.6. Further Resources
19. Portlet MVC Framework
19.1. Introduction
19.1.1. Controllers - The C in MVC
19.1.2. Views - The V in MVC
19.1.3. Web-scoped beans
19.2. The DispatcherPortlet
19.3. The ViewRendererServlet
19.4. Controllers
19.4.1. AbstractController and PortletContentGenerator
19.4.2. Other simple controllers
19.4.3. Command Controllers
19.4.4. PortletWrappingController
19.5. Handler mappings
19.5.1. PortletModeHandlerMapping
19.5.2. ParameterHandlerMapping
19.5.3. PortletModeParameterHandlerMapping
19.5.4. Adding HandlerInterceptors
19.5.5. HandlerInterceptorAdapter
19.5.6. ParameterMappingInterceptor
19.6. Views and resolving them
19.7. Multipart (file upload) support
19.7.1. Using the PortletMultipartResolver
19.7.2. Handling a file upload in a form
19.8. Handling exceptions
19.9. Annotation-based controller configuration
19.9.1. Setting up the dispatcher for annotation support
19.9.2. Defining a controller with @Controller
19.9.3. Mapping requests with @RequestMapping
19.9.4. Supported handler method arguments
19.9.5. Binding request parameters to method parameters with @RequestParam
19.9.6. Providing a link to data from the model with @ModelAttribute
19.9.7. Specifying attributes to store in a Session with @SessionAttributes
19.9.8. Customizing WebDataBinder initialization
Customizing data binding with @InitBinder
Configuring a custom WebBindingInitializer
19.10. Portlet application deployment
20. WebSocket Support
20.1. Introduction
20.1.1. WebSocket Fallback Options
20.1.2. A Messaging Architecture
20.1.3. Sub-Protocol Support in WebSocket
20.1.4. Should I Use WebSocket?
20.2. WebSocket API
20.2.1. Create and Configure a WebSocketHandler
20.2.2. Customizing the WebSocket Handshake
20.2.3. WebSocketHandler Decoration
20.2.4. Deployment Considerations
20.2.5. Configuring the WebSocket Engine
20.3. SockJS Fallback Options
20.3.1. Overview of SockJS
20.3.2. Enable SockJS
20.3.3. HTTP Streaming in IE 8, 9: Ajax/XHR vs IFrame
20.3.4. Heartbeat Messages
20.3.5. Servlet 3 Async Requests
20.3.6. CORS Headers for SockJS
20.4. STOMP Over WebSocket Messaging Architecture
20.4.1. Overview of STOMP
20.4.2. Enable STOMP over WebSocket
20.4.3. Flow of Messages
20.4.4. Annotation Message Handling
20.4.5. Sending Messages
20.4.6. Simple Broker
20.4.7. Full-Featured Broker
20.4.8. Connections To Full-Featured Broker
20.4.9. Authentication
20.4.10. User Destinations
20.4.11. Configuration and Performance
20.4.12. Testing Annotated Controller Methods
VI. Integration
21. Remoting and web services using Spring
21.1. Introduction
21.2. Exposing services using RMI
21.2.1. Exporting the service using the RmiServiceExporter
21.2.2. Linking in the service at the client
21.3. Using Hessian or Burlap to remotely call services via HTTP
21.3.1. Wiring up the DispatcherServlet for Hessian and co.
21.3.2. Exposing your beans by using the HessianServiceExporter
21.3.3. Linking in the service on the client
21.3.4. Using Burlap
21.3.5. Applying HTTP basic authentication to a service exposed through Hessian or Burlap
21.4. Exposing services using HTTP invokers
21.4.1. Exposing the service object
21.4.2. Linking in the service at the client
21.5. Web services
21.5.1. Exposing servlet-based web services using JAX-WS
21.5.2. Exporting standalone web services using JAX-WS
21.5.3. Exporting web services using the JAX-WS RI’s Spring support
21.5.4. Accessing web services using JAX-WS
21.6. JMS
21.6.1. Server-side configuration
21.6.2. Client-side configuration
21.7. AMQP
21.8. Auto-detection is not implemented for remote interfaces
21.9. Considerations when choosing a technology
21.10. Accessing RESTful services on the Client
21.10.1. RestTemplate
Working with the URI
Dealing with request and response headers
21.10.2. HTTP Message Conversion
StringHttpMessageConverter
FormHttpMessageConverter
ByteArrayHttpMessageConverter
MarshallingHttpMessageConverter
MappingJackson2HttpMessageConverter (or MappingJacksonHttpMessageConverter with Jackson 1.x)
SourceHttpMessageConverter
BufferedImageHttpMessageConverter
21.10.3. Async RestTemplate
22. Enterprise JavaBeans (EJB) integration
22.1. Introduction
22.2. Accessing EJBs
22.2.1. Concepts
22.2.2. Accessing local SLSBs
22.2.3. Accessing remote SLSBs
22.2.4. Accessing EJB 2.x SLSBs versus EJB 3 SLSBs
22.3. Using Spring’s EJB implementation support classes
22.3.1. EJB 3 injection interceptor
23. JMS (Java Message Service)
23.1. Introduction
23.2. Using Spring JMS
23.2.1. JmsTemplate
23.2.2. Connections
Caching Messaging Resources
SingleConnectionFactory
CachingConnectionFactory
23.2.3. Destination Management
23.2.4. Message Listener Containers
SimpleMessageListenerContainer
DefaultMessageListenerContainer
23.2.5. Transaction management
23.3. Sending a Message
23.3.1. Using Message Converters
23.3.2. SessionCallback and ProducerCallback
23.4. Receiving a message
23.4.1. Synchronous Reception
23.4.2. Asynchronous Reception - Message-Driven POJOs
23.4.3. the SessionAwareMessageListener interface
23.4.4. the MessageListenerAdapter
23.4.5. Processing messages within transactions
23.5. Support for JCA Message Endpoints
23.6. JMS Namespace Support
24. JMX
24.1. Introduction
24.2. Exporting your beans to JMX
24.2.1. Creating an MBeanServer
24.2.2. Reusing an existing MBeanServer
24.2.3. Lazy-initialized MBeans
24.2.4. Automatic registration of MBeans
24.2.5. Controlling the registration behavior
24.3. Controlling the management interface of your beans
24.3.1. the MBeanInfoAssembler Interface
24.3.2. Using Source-Level Metadata (JDK 5.0 annotations)
24.3.3. Source-Level Metadata Types
24.3.4. the AutodetectCapableMBeanInfoAssembler interface
24.3.5. Defining management interfaces using Java interfaces
24.3.6. Using MethodNameBasedMBeanInfoAssembler
24.4. Controlling the ObjectNames for your beans
24.4.1. Reading ObjectNames from Properties
24.4.2. Using the MetadataNamingStrategy
24.4.3. Configuring annotation based MBean export
24.5. JSR-160 Connectors
24.5.1. Server-side Connectors
24.5.2. Client-side Connectors
24.5.3. JMX over Burlap/Hessian/SOAP
24.6. Accessing MBeans via Proxies
24.7. Notifications
24.7.1. Registering Listeners for Notifications
24.7.2. Publishing Notifications
24.8. Further Resources
25. JCA CCI
25.1. Introduction
25.2. Configuring CCI
25.2.1. Connector configuration
25.2.2. ConnectionFactory configuration in Spring
25.2.3. Configuring CCI connections
25.2.4. Using a single CCI connection
25.3. Using Spring’s CCI access support
25.3.1. Record conversion
25.3.2. the CciTemplate
25.3.3. DAO support
25.3.4. Automatic output record generation
25.3.5. Summary
25.3.6. Using a CCI Connection and Interaction directly
25.3.7. Example for CciTemplate usage
25.4. Modeling CCI access as operation objects
25.4.1. MappingRecordOperation
25.4.2. MappingCommAreaOperation
25.4.3. Automatic output record generation
25.4.4. Summary
25.4.5. Example for MappingRecordOperation usage
25.4.6. Example for MappingCommAreaOperation usage
25.5. Transactions
26. Email
26.1. Introduction
26.2. Usage
26.2.1. Basic MailSender and SimpleMailMessage usage
26.2.2. Using the JavaMailSender and the MimeMessagePreparator
26.3. Using the JavaMail MimeMessageHelper
26.3.1. Sending attachments and inline resources
Attachments
Inline resources
26.3.2. Creating email content using a templating library
A Velocity-based example
27. Task Execution and Scheduling
27.1. Introduction
27.2. The Spring TaskExecutor abstraction
27.2.1. TaskExecutor types
27.2.2. Using a TaskExecutor
27.3. The Spring TaskScheduler abstraction
27.3.1. the Trigger interface
27.3.2. Trigger implementations
27.3.3. TaskScheduler implementations
27.4. Annotation Support for Scheduling and Asynchronous Execution
27.4.1. Enable scheduling annotations
27.4.2. The @Scheduled Annotation
27.4.3. The @Async Annotation
27.4.4. Executor qualification with @Async
27.5. The Task Namespace
27.5.1. The scheduler element
27.5.2. The executor element
27.5.3. The scheduled-tasks element
27.6. Using the Quartz Scheduler
27.6.1. Using the JobDetailBean
27.6.2. Using the MethodInvokingJobDetailFactoryBean
27.6.3. Wiring up jobs using triggers and the SchedulerFactoryBean
28. Dynamic language support
28.1. Introduction
28.2. A first example
28.3. Defining beans that are backed by dynamic languages
28.3.1. Common concepts
The <lang:language/> element
Refreshable beans
Inline dynamic language source files
Understanding Constructor Injection in the context of dynamic-language-backed beans
28.3.2. JRuby beans
28.3.3. Groovy beans
Customizing Groovy objects via a callback
28.3.4. BeanShell beans
28.4. Scenarios
28.4.1. Scripted Spring MVC Controllers
28.4.2. Scripted Validators
28.5. Bits and bobs
28.5.1. AOP - advising scripted beans
28.5.2. Scoping
28.6. Further Resources
29. Cache Abstraction
29.1. Introduction
29.2. Understanding the cache abstraction
29.3. Declarative annotation-based caching
29.3.1. @Cacheable annotation
Default Key Generation
Custom Key Generation Declaration
Conditional caching
Available caching SpEL evaluation context
29.3.2. @CachePut annotation
29.3.3. @CacheEvict annotation
29.3.4. @Caching annotation
29.3.5. Enable caching annotations
29.3.6. Using custom annotations
29.4. Declarative XML-based caching
29.5. Configuring the cache storage
29.5.1. JDK ConcurrentMap-based Cache
29.5.2. EhCache-based Cache
29.5.3. GemFire-based Cache
29.5.4. Dealing with caches without a backing store
29.6. Plugging-in different back-end caches
29.7. How can I set the TTL/TTI/Eviction policy/XXX feature?
VII. Appendices
30. Migrating to Spring Framework 4.0
31. Classic Spring Usage
31.1. Classic ORM usage
31.1.1. Hibernate
the HibernateTemplate
Implementing Spring-based DAOs without callbacks
31.1.2. JDO
JdoTemplate and JdoDaoSupport
31.1.3. JPA
JpaTemplate and JpaDaoSupport
31.2. Classic Spring MVC
31.3. JMS Usage
31.3.1. JmsTemplate
31.3.2. Asynchronous Message Reception
31.3.3. Connections
31.3.4. Transaction Management
32. Classic Spring AOP Usage
32.1. Pointcut API in Spring
32.1.1. Concepts
32.1.2. Operations on pointcuts
32.1.3. AspectJ expression pointcuts
32.1.4. Convenience pointcut implementations
Static pointcuts
Dynamic pointcuts
32.1.5. Pointcut superclasses
32.1.6. Custom pointcuts
32.2. Advice API in Spring
32.2.1. Advice lifecycles
32.2.2. Advice types in Spring
Interception around advice
Before advice
Throws advice
After Returning advice
Introduction advice
32.3. Advisor API in Spring
32.4. Using the ProxyFactoryBean to create AOP proxies
32.4.1. Basics
32.4.2. JavaBean properties
32.4.3. JDK- and CGLIB-based proxies
32.4.4. Proxying interfaces
32.4.5. Proxying classes
32.4.6. Using global advisors
32.5. Concise proxy definitions
32.6. Creating AOP proxies programmatically with the ProxyFactory
32.7. Manipulating advised objects
32.8. Using the "autoproxy" facility
32.8.1. Autoproxy bean definitions
BeanNameAutoProxyCreator
DefaultAdvisorAutoProxyCreator
AbstractAdvisorAutoProxyCreator
32.8.2. Using metadata-driven auto-proxying
32.9. Using TargetSources
32.9.1. Hot swappable target sources
32.9.2. Pooling target sources
32.9.3. Prototype target sources
32.9.4. ThreadLocal target sources
32.10. Defining new Advice types
32.11. Further resources
33. XML Schema-based configuration
33.1. Introduction
33.2. XML Schema-based configuration
33.2.1. Referencing the schemas
33.2.2. the util schema
<util:constant/>
<util:property-path/>
<util:properties/>
<util:list/>
<util:map/>
<util:set/>
33.2.3. the jee schema
<jee:jndi-lookup/> (simple)
<jee:jndi-lookup/> (with single JNDI environment setting)
<jee:jndi-lookup/> (with multiple JNDI environment settings)
<jee:jndi-lookup/> (complex)
<jee:local-slsb/> (simple)
<jee:local-slsb/> (complex)
<jee:remote-slsb/>
33.2.4. the lang schema
33.2.5. the jms schema
33.2.6. the tx (transaction) schema
33.2.7. the aop schema
33.2.8. the context schema
<property-placeholder/>
<annotation-config/>
<component-scan/>
<load-time-weaver/>
<spring-configured/>
<mbean-export/>
33.2.9. the tool schema
33.2.10. the jdbc schema
33.2.11. the cache schema
33.2.12. the beans schema
34. Extensible XML authoring
34.1. Introduction
34.2. Authoring the schema
34.3. Coding a NamespaceHandler
34.4. nDefinitionParser
34.5. Registering the handler and the schema
34.5.1. META-INF/spring.handlers
34.5.2. META-INF/spring.schemas
34.6. Using a custom extension in your Spring XML configuration
34.7. Meatier examples
34.7.1. Nesting custom tags within custom tags
34.7.2. Custom attributes on normal elements
34.8. Further Resources
35. spring.tld
35.1. Introduction
35.2. the bind tag
35.3. the escapeBody tag
35.4. the hasBindErrors tag
35.5. the htmlEscape tag
35.6. the message tag
35.7. the nestedPath tag
35.8. the theme tag
35.9. the transform tag
35.10. the url tag
35.11. the eval tag
36. spring-form.tld
36.1. Introduction
36.2. the checkbox tag
36.3. the checkboxes tag
36.4. the errors tag
36.5. the form tag
36.6. the hidden tag
36.7. the input tag
36.8. the label tag
36.9. the option tag
36.10. the options tag
36.11. the password tag
36.12. the radiobutton tag
36.13. the radiobuttons tag
36.14. the select tag
36.15. the textarea tag