Spring Framework

Reference Documentation

3.1

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. Introduction to Spring Framework
1.1. Dependency Injection and Inversion of Control
1.2. Modules
1.2.1. Core Container
1.2.2. Data Access/Integration
1.2.3. Web
1.2.4. AOP and Instrumentation
1.2.5. Test
1.3. Usage scenarios
1.3.1. Dependency Management and Naming Conventions
1.3.1.1. Spring Dependencies and Depending on Spring
1.3.1.2. Maven Dependency Management
1.3.1.3. Ivy Dependency Management
1.3.2. Logging
1.3.2.1. Not Using Commons Logging
1.3.2.2. Using SLF4J
1.3.2.3. Using Log4J
II. What's New in Spring 3
2. New Features and Enhancements in Spring 3.0
2.1. Java 5
2.2. Improved documentation
2.3. New articles and tutorials
2.4. New module organization and build system
2.5. Overview of new features
2.5.1. Core APIs updated for Java 5
2.5.2. Spring Expression Language
2.5.3. The Inversion of Control (IoC) container
2.5.3.1. Java based bean metadata
2.5.3.2. Defining bean metadata within components
2.5.4. General purpose type conversion system and field formatting system
2.5.5. The Data Tier
2.5.6. The Web Tier
2.5.6.1. Comprehensive REST support
2.5.6.2. @MVC additions
2.5.7. Declarative model validation
2.5.8. Early support for Java EE 6
2.5.9. Support for embedded databases
3. New Features and Enhancements in Spring 3.1
3.1. Overview of new features
3.1.1. Cache Abstraction
3.1.2. Bean Definition Profiles
3.1.3. Environment Abstraction
3.1.4. PropertySource Abstraction
3.1.5. Code equivalents for Spring's XML namespaces
3.1.6. Support for Hibernate 4.x
3.1.7. TestContext framework support for @Configuration classes and bean definition profiles
3.1.8. c: namespace for more concise constructor injection
3.1.9. Support for injection against non-standard JavaBeans setters
3.1.10. Support for Servlet 3 code-based configuration of Servlet Container
3.1.11. Support for Servlet 3 MultipartResolver
3.1.12. JPA EntityManagerFactory bootstrapping without persistence.xml
3.1.13. New HandlerMethod-based Support Classes For Annotated Controller Processing
3.1.14. "consumes" and "produces" conditions in @RequestMapping
3.1.15. Flash Attributes and RedirectAttributes
3.1.16. URI Template Variable Enhancements
3.1.17. @Valid On @RequestBody Controller Method Arguments
3.1.18. @RequestPart Annotation On Controller Method Arguments
3.1.19. UriComponentsBuilder and UriComponents
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
4.2.2.1. Composing XML-based configuration metadata
4.2.3. Using the container
4.3. Bean overview
4.3.1. Naming beans
4.3.1.1. Aliasing a bean outside the bean definition
4.3.2. Instantiating beans
4.3.2.1. Instantiation with a constructor
4.3.2.2. Instantiation with a static factory method
4.3.2.3. Instantiation using an instance factory method
4.4. Dependencies
4.4.1. Dependency injection
4.4.1.1. Constructor-based dependency injection
4.4.1.2. Setter-based dependency injection
4.4.1.3. Dependency resolution process
4.4.1.4. Examples of dependency injection
4.4.2. Dependencies and configuration in detail
4.4.2.1. Straight values (primitives, Strings, and so on)
4.4.2.2. References to other beans (collaborators)
4.4.2.3. Inner beans
4.4.2.4. Collections
4.4.2.5. Null and empty string values
4.4.2.6. XML shortcut with the p-namespace
4.4.2.7. XML shortcut with the c-namespace
4.4.2.8. Compound property names
4.4.3. Using depends-on
4.4.4. Lazy-initialized beans
4.4.5. Autowiring collaborators
4.4.5.1. Limitations and disadvantages of autowiring
4.4.5.2. Excluding a bean from autowiring
4.4.6. Method injection
4.4.6.1. Lookup method injection
4.4.6.2. 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
4.5.4.1. Initial web configuration
4.5.4.2. Request scope
4.5.4.3. Session scope
4.5.4.4. Global session scope
4.5.4.5. Scoped beans as dependencies
4.5.5. Custom scopes
4.5.5.1. Creating a custom scope
4.5.5.2. Using a custom scope
4.6. Customizing the nature of a bean
4.6.1. Lifecycle callbacks
4.6.1.1. Initialization callbacks
4.6.1.2. Destruction callbacks
4.6.1.3. Default initialization and destroy methods
4.6.1.4. Combining lifecycle mechanisms
4.6.1.5. Startup and shutdown callbacks
4.6.1.6. 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
4.8.1.1. Example: Hello World, BeanPostProcessor-style
4.8.1.2. Example: The RequiredAnnotationBeanPostProcessor
4.8.2. Customizing configuration metadata with a BeanFactoryPostProcessor
4.8.2.1. Example: the PropertyPlaceholderConfigurer
4.8.2.2. 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. CustomAutowireConfigurer
4.9.5. @Resource
4.9.6. @PostConstruct and @PreDestroy
4.10. Classpath scanning and managed components
4.10.1. @Component and further stereotype annotations
4.10.2. Automatically detecting classes and registering bean definitions
4.10.3. Using filters to customize scanning
4.10.4. Defining bean metadata within components
4.10.5. Naming autodetected components
4.10.6. Providing a scope for autodetected components
4.10.7. 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: @Configuration and @Bean
4.12.2. Instantiating the Spring container using AnnotationConfigApplicationContext
4.12.2.1. Simple construction
4.12.2.2. Building the container programmatically using register(Class<?>...)
4.12.2.3. Enabling component scanning with scan(String...)
4.12.2.4. Support for web applications with AnnotationConfigWebApplicationContext
4.12.3. Composing Java-based configurations
4.12.3.1. Using the @Import annotation
4.12.3.2. Combining Java and XML configuration
4.12.4. Using the @Bean annotation
4.12.4.1. Declaring a bean
4.12.4.2. Injecting dependencies
4.12.4.3. Receiving lifecycle callbacks
4.12.4.4. Specifying bean scope
4.12.4.5. Customizing bean naming
4.12.4.6. Bean aliasing
4.12.5. Further information about how Java-based configuration works internally
4.13. Registering a LoadTimeWeaver
4.14. Additional Capabilities of the ApplicationContext
4.14.1. Internationalization using MessageSource
4.14.2. Standard and Custom Events
4.14.3. Convenient access to low-level resources
4.14.4. Convenient ApplicationContext instantiation for web applications
4.14.5. Deploying a Spring ApplicationContext as a J2EE RAR file
4.15. The BeanFactory
4.15.1. BeanFactory or ApplicationContext?
4.15.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
5.7.1.1. Constructing ClassPathXmlApplicationContext instances - shortcuts
5.7.2. Wildcards in application context constructor resource paths
5.7.2.1. Ant-style Patterns
5.7.2.2. The classpath*: prefix
5.7.2.3. 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
6.4.2.1. Registering additional custom PropertyEditors
6.5. Spring 3 Type Conversion
6.5.1. Converter SPI
6.5.2. ConverterFactory
6.5.3. GenericConverter
6.5.3.1. ConditionalGenericConverter
6.5.4. ConversionService API
6.5.5. Configuring a ConversionService
6.5.6. Using a ConversionService programatically
6.6. Spring 3 Field Formatting
6.6.1. Formatter SPI
6.6.2. Annotation-driven Formatting
6.6.2.1. Format Annotation API
6.6.3. FormatterRegistry SPI
6.6.4. FormatterRegistrar SPI
6.6.5. Configuring Formatting in Spring MVC
6.7. Spring 3 Validation
6.7.1. Overview of the JSR-303 Bean Validation API
6.7.2. Configuring a Bean Validation Implementation
6.7.2.1. Injecting a Validator
6.7.2.2. Configuring Custom Constraints
6.7.2.3. Additional Configuration Options
6.7.3. Configuring a DataBinder
6.7.4. Spring MVC 3 Validation
6.7.4.1. Triggering @Controller Input Validation
6.7.4.2. Configuring a Validator for use by Spring MVC
6.7.4.3. Configuring a JSR-303 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
7.3.1.1. 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
7.5.6.1. Relational operators
7.5.6.2. Logical operators
7.5.6.3. Mathematical operators
7.5.7. Assignment
7.5.8. Types
7.5.9. Constructors
7.5.10. Variables
7.5.10.1. 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
8.2.2. Declaring an aspect
8.2.3. Declaring a pointcut
8.2.3.1. Supported Pointcut Designators
8.2.3.2. Combining pointcut expressions
8.2.3.3. Sharing common pointcut definitions
8.2.3.4. Examples
8.2.3.5. Writing good pointcuts
8.2.4. Declaring advice
8.2.4.1. Before advice
8.2.4.2. After returning advice
8.2.4.3. After throwing advice
8.2.4.4. After (finally) advice
8.2.4.5. Around advice
8.2.4.6. Advice parameters
8.2.4.7. 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
8.3.3.1. Before advice
8.3.3.2. After returning advice
8.3.3.3. After throwing advice
8.3.3.4. After (finally) advice
8.3.3.5. Around advice
8.3.3.6. Advice parameters
8.3.3.7. 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
8.8.1.1. Unit testing @Configurable objects
8.8.1.2. 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
8.8.4.1. A first example
8.8.4.2. Aspects
8.8.4.3. 'META-INF/aop.xml'
8.8.4.4. Required libraries (JARS)
8.8.4.5. Spring configuration
8.8.4.6. 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
9.2.4.1. Static pointcuts
9.2.4.2. 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
9.3.2.1. Interception around advice
9.3.2.2. Before advice
9.3.2.3. Throws advice
9.3.2.4. After Returning advice
9.3.2.5. 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 "autoproxy" facility
9.9.1. Autoproxy bean definitions
9.9.1.1. BeanNameAutoProxyCreator
9.9.1.2. DefaultAdvisorAutoProxyCreator
9.9.1.3. 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
10.2.1.1. JNDI
10.2.1.2. Servlet API
10.2.1.3. Portlet API
10.2.2. Unit Testing support Classes
10.2.2.1. General utilities
10.2.2.2. Spring MVC
10.3. Integration Testing
10.3.1. Overview
10.3.2. Goals of Integration Testing
10.3.2.1. Context management and caching
10.3.2.2. Dependency Injection of test fixtures
10.3.2.3. Transaction management
10.3.2.4. Support classes for integration testing
10.3.3. JDBC Testing Support
10.3.4. Annotations
10.3.4.1. Spring Testing Annotations
10.3.4.2. Standard Annotation Support
10.3.4.3. Spring JUnit Testing Annotations
10.3.5. Spring TestContext Framework
10.3.5.1. Key abstractions
10.3.5.2. Context management
10.3.5.3. Dependency injection of test fixtures
10.3.5.4. Transaction management
10.3.5.5. TestContext support classes
10.3.6. 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
11.5.6.1. @Transactional settings
11.5.6.2. Multiple Transaction Managers with @Transactional
11.5.6.3. Custom shortcut annotations
11.5.7. Transaction propagation
11.5.7.1. Required
11.5.7.2. RequiresNew
11.5.7.3. 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
11.6.1.1. 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. BEA WebLogic Server
11.8.3. Oracle OC4J
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
13.2.1.1. Examples of JdbcTemplate class usage
13.2.1.2. JdbcTemplate best practices
13.2.2. NamedParameterJdbcTemplate
13.2.3. SimpleJdbcTemplate
13.2.4. SQLExceptionTranslator
13.2.5. Executing statements
13.2.6. Running queries
13.2.7. Updating the database
13.2.8. 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
13.9.1.1. 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
14.5.1.1. LocalEntityManagerFactoryBean
14.5.1.2. Obtaining an EntityManagerFactory from JNDI
14.5.1.3. LocalContainerEntityManagerFactoryBean
14.5.1.4. Dealing with multiple persistence units
14.5.2. Implementing DAOs based on plain JPA
14.5.3. Transaction Management
14.5.4. JpaDialect
14.6. iBATIS SQL Maps
14.6.1. Setting up the SqlMapClient
14.6.2. Using SqlMapClientTemplate and SqlMapClientDaoSupport
14.6.3. Implementing DAOs based on plain iBATIS API
15. Marshalling XML using O/X Mappers
15.1. Introduction
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
15.5.1.1. XML Schema-based Configuration
15.6. Castor
15.6.1. CastorMarshaller
15.6.2. Mapping
15.7. XMLBeans
15.7.1. XmlBeansMarshaller
15.7.1.1. XML Schema-based Configuration
15.8. JiBX
15.8.1. JibxMarshaller
15.8.1.1. 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
16.3.2.1. New Support Classes for @RequestMapping methods in Spring MVC 3.1
16.3.2.2. URI Template Patterns
16.3.2.3. URI Template Patterns with Regular Expressions
16.3.2.4. Path Patterns
16.3.2.5. Consumable Media Types
16.3.2.6. Producible Media Types
16.3.2.7. Request Parameters and Header Values
16.3.3. Defining @RequestMapping handler methods
16.3.3.1. Supported method argument types
16.3.3.2. Supported method return types
16.3.3.3. Binding request parameters to method parameters with @RequestParam
16.3.3.4. Mapping the request body with the @RequestBody annotation
16.3.3.5. Mapping the response body with the @ResponseBody annotation
16.3.3.6. Using HttpEntity<?>
16.3.3.7. Using @ModelAttribute on a method
16.3.3.8. Using @ModelAttribute on a method argument
16.3.3.9. Using @SessionAttributes to store model attributes in the HTTP session between requests
16.3.3.10. Specifying redirect and flash attributes
16.3.3.11. Working with "application/x-www-form-urlencoded" data
16.3.3.12. Mapping cookie values with the @CookieValue annotation
16.3.3.13. Mapping request header attributes with the @RequestHeader annotation
16.3.3.14. Method Parameters And Type Conversion
16.3.3.15. Customizing WebDataBinder initialization
16.3.3.16. Support for the 'Last-Modified' Response Header To Facilitate Content Caching
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
16.5.3.1. RedirectView
16.5.3.2. The redirect: prefix
16.5.3.3. The forward: prefix
16.5.4. ContentNegotiatingViewResolver
16.6. Using flash attributes
16.7. Building URIs
16.8. Using locales
16.8.1. AcceptHeaderLocaleResolver
16.8.2. CookieLocaleResolver
16.8.3. SessionLocaleResolver
16.8.4. LocaleChangeInterceptor
16.9. Using themes
16.9.1. Overview of themes
16.9.2. Defining themes
16.9.3. Theme resolvers
16.10. Spring's multipart (file upload) support
16.10.1. Introduction
16.10.2. Using a MultipartResolver with Commons FileUpload
16.10.3. Using a MultipartResolver with Servlet 3.0
16.10.4. Handling a file upload in a form
16.10.5. Handling a file upload request from programmatic clients
16.11. Handling exceptions
16.11.1. HandlerExceptionResolver
16.11.2. @ExceptionHandler
16.12. Convention over configuration support
16.12.1. The Controller ControllerClassNameHandlerMapping
16.12.2. The Model ModelMap (ModelAndView)
16.12.3. The View - RequestToViewNameTranslator
16.13. ETag support
16.14. Configuring Spring MVC
16.14.1. Enabling MVC Java Config or the MVC XML Namespace
16.14.2. Customizing the Provided Configuration
16.14.3. Configuring Interceptors
16.14.4. Configuring View Controllers
16.14.5. Configuring Serving of Resources
16.14.6. mvc:default-servlet-handler
16.14.7. More Spring Web MVC Resources
16.14.8. Advanced Customizations with MVC Java Config
16.14.9. 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
17.2.4.1. Configuration
17.2.4.2. The form tag
17.2.4.3. The input tag
17.2.4.4. The checkbox tag
17.2.4.5. The checkboxes tag
17.2.4.6. The radiobutton tag
17.2.4.7. The radiobuttons tag
17.2.4.8. The password tag
17.2.4.9. The select tag
17.2.4.10. The option tag
17.2.4.11. The options tag
17.2.4.12. The textarea tag
17.2.4.13. The hidden tag
17.2.4.14. The errors tag
17.2.4.15. HTTP Method Conversion
17.2.4.16. HTML5 Tags
17.3. Tiles
17.3.1. Dependencies
17.3.2. How to integrate Tiles
17.3.2.1. UrlBasedViewResolver
17.3.2.2. ResourceBundleViewResolver
17.3.2.3. 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
17.4.4.1. velocity.properties
17.4.4.2. FreeMarker
17.4.5. Bind support and form handling
17.4.5.1. The bind macros
17.4.5.2. Simple binding
17.4.5.3. Form input generation macros
17.4.5.4. HTML escaping and XHTML compliance
17.5. XSLT
17.5.1. My First Words
17.5.1.1. Bean definitions
17.5.1.2. Standard MVC controller code
17.5.1.3. Convert the model data to XML
17.5.1.4. Defining the view properties
17.5.1.5. Document transformation
17.5.2. Summary
17.6. Document views (PDF/Excel)
17.6.1. Introduction
17.6.2. Configuration and setup
17.6.2.1. Document view definitions
17.6.2.2. Controller code
17.6.2.3. Subclassing for Excel views
17.6.2.4. Subclassing for PDF views
17.7. JasperReports
17.7.1. Dependencies
17.7.2. Configuration
17.7.2.1. Configuring the ViewResolver
17.7.2.2. Configuring the Views
17.7.2.3. About Report Files
17.7.2.4. Using JasperReportsMultiFormatView
17.7.3. Populating the ModelAndView
17.7.4. Working with Sub-Reports
17.7.4.1. Configuring Sub-Report Files
17.7.4.2. 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.1 and 1.2
18.3.1. DelegatingVariableResolver (JSF 1.1/1.2)
18.3.2. SpringBeanVariableResolver (JSF 1.1/1.2)
18.3.3. SpringBeanFacesELResolver (JSF 1.2+)
18.3.4. FacesContextUtils
18.4. Apache Struts 1.x and 2.x
18.4.1. ContextLoaderPlugin
18.4.1.1. DelegatingRequestProcessor
18.4.1.2. DelegatingActionProxy
18.4.2. ActionSupport Classes
18.5. WebWork 2.x
18.6. Tapestry 3.x and 4.x
18.6.1. Injecting Spring-managed beans
18.6.1.1. Dependency Injecting Spring Beans into Tapestry pages
18.6.1.2. Component definition files
18.6.1.3. Adding abstract accessors
18.6.1.4. Dependency Injecting Spring Beans into Tapestry pages - Tapestry 4.x style
18.7. 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
19.9.8.1. Customizing data binding with @InitBinder
19.9.8.2. Configuring a custom WebBindingInitializer
19.10. Portlet application deployment
VI. Integration
20. Remoting and web services using Spring
20.1. Introduction
20.2. Exposing services using RMI
20.2.1. Exporting the service using the RmiServiceExporter
20.2.2. Linking in the service at the client
20.3. Using Hessian or Burlap to remotely call services via HTTP
20.3.1. Wiring up the DispatcherServlet for Hessian and co.
20.3.2. Exposing your beans by using the HessianServiceExporter
20.3.3. Linking in the service on the client
20.3.4. Using Burlap
20.3.5. Applying HTTP basic authentication to a service exposed through Hessian or Burlap
20.4. Exposing services using HTTP invokers
20.4.1. Exposing the service object
20.4.2. Linking in the service at the client
20.5. Web services
20.5.1. Exposing servlet-based web services using JAX-RPC
20.5.2. Accessing web services using JAX-RPC
20.5.3. Registering JAX-RPC Bean Mappings
20.5.4. Registering your own JAX-RPC Handler
20.5.5. Exposing servlet-based web services using JAX-WS
20.5.6. Exporting standalone web services using JAX-WS
20.5.7. Exporting web services using the JAX-WS RI's Spring support
20.5.8. Accessing web services using JAX-WS
20.6. JMS
20.6.1. Server-side configuration
20.6.2. Client-side configuration
20.7. Auto-detection is not implemented for remote interfaces
20.8. Considerations when choosing a technology
20.9. Accessing RESTful services on the Client
20.9.1. RestTemplate
20.9.1.1. Working with the URI
20.9.1.2. Dealing with request and response headers
20.9.2. HTTP Message Conversion
20.9.2.1. StringHttpMessageConverter
20.9.2.2. FormHttpMessageConverter
20.9.2.3. ByteArrayHttpMessageConverter
20.9.2.4. MarshallingHttpMessageConverter
20.9.2.5. MappingJacksonHttpMessageConverter
20.9.2.6. SourceHttpMessageConverter
20.9.2.7. BufferedImageHttpMessageConverter
21. Enterprise JavaBeans (EJB) integration
21.1. Introduction
21.2. Accessing EJBs
21.2.1. Concepts
21.2.2. Accessing local SLSBs
21.2.3. Accessing remote SLSBs
21.2.4. Accessing EJB 2.x SLSBs versus EJB 3 SLSBs
21.3. Using Spring's EJB implementation support classes
21.3.1. EJB 2.x base classes
21.3.2. EJB 3 injection interceptor
22. JMS (Java Message Service)
22.1. Introduction
22.2. Using Spring JMS
22.2.1. JmsTemplate
22.2.2. Connections
22.2.2.1. Caching Messaging Resources
22.2.2.2. SingleConnectionFactory
22.2.2.3. CachingConnectionFactory
22.2.3. Destination Management
22.2.4. Message Listener Containers
22.2.4.1. SimpleMessageListenerContainer
22.2.4.2. DefaultMessageListenerContainer
22.2.5. Transaction management
22.3. Sending a Message
22.3.1. Using Message Converters
22.3.2. SessionCallback and ProducerCallback
22.4. Receiving a message
22.4.1. Synchronous Reception
22.4.2. Asynchronous Reception - Message-Driven POJOs
22.4.3. The SessionAwareMessageListener interface
22.4.4. The MessageListenerAdapter
22.4.5. Processing messages within transactions
22.5. Support for JCA Message Endpoints
22.6. JMS Namespace Support
23. JMX
23.1. Introduction
23.2. Exporting your beans to JMX
23.2.1. Creating an MBeanServer
23.2.2. Reusing an existing MBeanServer
23.2.3. Lazy-initialized MBeans
23.2.4. Automatic registration of MBeans
23.2.5. Controlling the registration behavior
23.3. Controlling the management interface of your beans
23.3.1. The MBeanInfoAssembler Interface
23.3.2. Using Source-Level Metadata (JDK 5.0 annotations)
23.3.3. Source-Level Metadata Types
23.3.4. The AutodetectCapableMBeanInfoAssembler interface
23.3.5. Defining management interfaces using Java interfaces
23.3.6. Using MethodNameBasedMBeanInfoAssembler
23.4. Controlling the ObjectNames for your beans
23.4.1. Reading ObjectNames from Properties
23.4.2. Using the MetadataNamingStrategy
23.4.3. The <context:mbean-export/> element
23.5. JSR-160 Connectors
23.5.1. Server-side Connectors
23.5.2. Client-side Connectors
23.5.3. JMX over Burlap/Hessian/SOAP
23.6. Accessing MBeans via Proxies
23.7. Notifications
23.7.1. Registering Listeners for Notifications
23.7.2. Publishing Notifications
23.8. Further Resources
24. JCA CCI
24.1. Introduction
24.2. Configuring CCI
24.2.1. Connector configuration
24.2.2. ConnectionFactory configuration in Spring
24.2.3. Configuring CCI connections
24.2.4. Using a single CCI connection
24.3. Using Spring's CCI access support
24.3.1. Record conversion
24.3.2. The CciTemplate
24.3.3. DAO support
24.3.4. Automatic output record generation
24.3.5. Summary
24.3.6. Using a CCI Connection and Interaction directly
24.3.7. Example for CciTemplate usage
24.4. Modeling CCI access as operation objects
24.4.1. MappingRecordOperation
24.4.2. MappingCommAreaOperation
24.4.3. Automatic output record generation
24.4.4. Summary
24.4.5. Example for MappingRecordOperation usage
24.4.6. Example for MappingCommAreaOperation usage
24.5. Transactions
25. Email
25.1. Introduction
25.2. Usage
25.2.1. Basic MailSender and SimpleMailMessage usage
25.2.2. Using the JavaMailSender and the MimeMessagePreparator
25.3. Using the JavaMail MimeMessageHelper
25.3.1. Sending attachments and inline resources
25.3.1.1. Attachments
25.3.1.2. Inline resources
25.3.2. Creating email content using a templating library
25.3.2.1. A Velocity-based example
26. Task Execution and Scheduling
26.1. Introduction
26.2. The Spring TaskExecutor abstraction
26.2.1. TaskExecutor types
26.2.2. Using a TaskExecutor
26.3. The Spring TaskScheduler abstraction
26.3.1. The Trigger interface
26.3.2. Trigger implementations
26.3.3. TaskScheduler implementations
26.4. The Task Namespace
26.4.1. The 'scheduler' element
26.4.2. The 'executor' element
26.4.3. The 'scheduled-tasks' element
26.5. Annotation Support for Scheduling and Asynchronous Execution
26.5.1. The @Scheduled Annotation
26.5.2. The @Async Annotation
26.5.3. The <annotation-driven> Element
26.5.4. Executor qualification with @Async
26.6. Using the Quartz Scheduler
26.6.1. Using the JobDetailBean
26.6.2. Using the MethodInvokingJobDetailFactoryBean
26.6.3. Wiring up jobs using triggers and the SchedulerFactoryBean
26.7. Using JDK Timer support
26.7.1. Creating custom timers
26.7.2. Using the MethodInvokingTimerTaskFactoryBean
26.7.3. Wrapping up: setting up the tasks using the TimerFactoryBean
27. Dynamic language support
27.1. Introduction
27.2. A first example
27.3. Defining beans that are backed by dynamic languages
27.3.1. Common concepts
27.3.1.1. The <lang:language/> element
27.3.1.2. Refreshable beans
27.3.1.3. Inline dynamic language source files
27.3.1.4. Understanding Constructor Injection in the context of dynamic-language-backed beans
27.3.2. JRuby beans
27.3.3. Groovy beans
27.3.3.1. Customising Groovy objects via a callback
27.3.4. BeanShell beans
27.4. Scenarios
27.4.1. Scripted Spring MVC Controllers
27.4.2. Scripted Validators
27.5. Bits and bobs
27.5.1. AOP - advising scripted beans
27.5.2. Scoping
27.6. Further Resources
28. Cache Abstraction
28.1. Introduction
28.2. Understanding the cache abstraction
28.3. Declarative annotation-based caching
28.3.1. @Cacheable annotation
28.3.1.1. Default Key Generation
28.3.1.2. Custom Key Generation Declaration
28.3.1.3. Conditional caching
28.3.1.4. Available caching SpEL evaluation context
28.3.2. @CachePut annotation
28.3.3. @CacheEvict annotation
28.3.4. @Caching annotation
28.3.5. Enable caching annotations
28.3.6. Using custom annotations
28.4. Declarative XML-based caching
28.5. Configuring the cache storage
28.5.1. JDK ConcurrentMap-based Cache
28.5.2. Ehcache-based Cache
28.5.3. Dealing with caches without a backing store
28.6. Plugging-in different back-end caches
28.7. How can I set the TTL/TTI/Eviction policy/XXX feature?
VII. Appendices
A. Classic Spring Usage
A.1. Classic ORM usage
A.1.1. Hibernate
A.1.1.1. The HibernateTemplate
A.1.1.2. Implementing Spring-based DAOs without callbacks
A.1.2. JDO
A.1.2.1. JdoTemplate and JdoDaoSupport
A.1.3. JPA
A.1.3.1. JpaTemplate and JpaDaoSupport
A.2. Classic Spring MVC
A.3. JMS Usage
A.3.1. JmsTemplate
A.3.2. Asynchronous Message Reception
A.3.3. Connections
A.3.4. Transaction Management
B. Classic Spring AOP Usage
B.1. Pointcut API in Spring
B.1.1. Concepts
B.1.2. Operations on pointcuts
B.1.3. AspectJ expression pointcuts
B.1.4. Convenience pointcut implementations
B.1.4.1. Static pointcuts
B.1.4.2. Dynamic pointcuts
B.1.5. Pointcut superclasses
B.1.6. Custom pointcuts
B.2. Advice API in Spring
B.2.1. Advice lifecycles
B.2.2. Advice types in Spring
B.2.2.1. Interception around advice
B.2.2.2. Before advice
B.2.2.3. Throws advice
B.2.2.4. After Returning advice
B.2.2.5. Introduction advice
B.3. Advisor API in Spring
B.4. Using the ProxyFactoryBean to create AOP proxies
B.4.1. Basics
B.4.2. JavaBean properties
B.4.3. JDK- and CGLIB-based proxies
B.4.4. Proxying interfaces
B.4.5. Proxying classes
B.4.6. Using 'global' advisors
B.5. Concise proxy definitions
B.6. Creating AOP proxies programmatically with the ProxyFactory
B.7. Manipulating advised objects
B.8. Using the "autoproxy" facility
B.8.1. Autoproxy bean definitions
B.8.1.1. BeanNameAutoProxyCreator
B.8.1.2. DefaultAdvisorAutoProxyCreator
B.8.1.3. AbstractAdvisorAutoProxyCreator
B.8.2. Using metadata-driven auto-proxying
B.9. Using TargetSources
B.9.1. Hot swappable target sources
B.9.2. Pooling target sources
B.9.3. Prototype target sources
B.9.4. ThreadLocal target sources
B.10. Defining new Advice types
B.11. Further resources
C. XML Schema-based configuration
C.1. Introduction
C.2. XML Schema-based configuration
C.2.1. Referencing the schemas
C.2.2. The util schema
C.2.2.1. <util:constant/>
C.2.2.2. <util:property-path/>
C.2.2.3. <util:properties/>
C.2.2.4. <util:list/>
C.2.2.5. <util:map/>
C.2.2.6. <util:set/>
C.2.3. The jee schema
C.2.3.1. <jee:jndi-lookup/> (simple)
C.2.3.2. <jee:jndi-lookup/> (with single JNDI environment setting)
C.2.3.3. <jee:jndi-lookup/> (with multiple JNDI environment settings)
C.2.3.4. <jee:jndi-lookup/> (complex)
C.2.3.5. <jee:local-slsb/> (simple)
C.2.3.6. <jee:local-slsb/> (complex)
C.2.3.7. <jee:remote-slsb/>
C.2.4. The lang schema
C.2.5. The jms schema
C.2.6. The tx (transaction) schema
C.2.7. The aop schema
C.2.8. The context schema
C.2.8.1. <property-placeholder/>
C.2.8.2. <annotation-config/>
C.2.8.3. <component-scan/>
C.2.8.4. <load-time-weaver/>
C.2.8.5. <spring-configured/>
C.2.8.6. <mbean-export/>
C.2.9. The tool schema
C.2.10. The beans schema
D. Extensible XML authoring
D.1. Introduction
D.2. Authoring the schema
D.3. Coding a NamespaceHandler
D.4. Coding a BeanDefinitionParser
D.5. Registering the handler and the schema
D.5.1. 'META-INF/spring.handlers'
D.5.2. 'META-INF/spring.schemas'
D.6. Using a custom extension in your Spring XML configuration
D.7. Meatier examples
D.7.1. Nesting custom tags within custom tags
D.7.2. Custom attributes on 'normal' elements
D.8. Further Resources
E. spring-beans-2.0.dtd
F. spring.tld
F.1. Introduction
F.2. The bind tag
F.3. The escapeBody tag
F.4. The hasBindErrors tag
F.5. The htmlEscape tag
F.6. The message tag
F.7. The nestedPath tag
F.8. The theme tag
F.9. The transform tag
F.10. The url tag
F.11. The eval tag
G. spring-form.tld
G.1. Introduction
G.2. The checkbox tag
G.3. The checkboxes tag
G.4. The errors tag
G.5. The form tag
G.6. The hidden tag
G.7. The input tag
G.8. The label tag
G.9. The option tag
G.10. The options tag
G.11. The password tag
G.12. The radiobutton tag
G.13. The radiobuttons tag
G.14. The select tag
G.15. The textarea tag