You are previewing Spring MVC: A Tutorial (Second Edition).
O'Reilly logo
Spring MVC: A Tutorial (Second Edition)

Book Description

This book is an easy to follow tutorial on Spring MVC, a modern web application framework that is part of the Spring Framework. The MVC in Spring MVC stands for Model-View-Controller, a design pattern widely used in Graphical User Interface (GUI) development. This pattern is not only common in web development, but is also used in desktop technology like Java Swing. Sometimes called Spring Web MVC, Spring MVC is one of the most popular web frameworks today and a most sought-after skill. This book is for anyone wishing to learn to develop Java-based web applications with Spring MVC. Sample applications come as Spring Tool Suite and Eclipse projects.

Table of Contents

  1. Introduction
    1. The Hypertext Transfer Protocol (HTTP)
    2. Servlet and JSP Overview
    3. Downloading Spring or Using STS with Maven/Gradle
    4. About This Book
    5. Downloading the Sample Applications
  2. Chapter 1: The Spring Framework
    1. Dependency Injection
    2. XML-Based Spring Configuration
    3. Using Spring to Manage Dependencies
    4. Summary
  3. Chapter 2: Model 2 and the MVC Pattern
    1. Model 1 Overview
    2. Model 2 Overview
    3. Model 2 with A Servlet Controller
    4. Model 2 with A Filter Dispatcher
    5. Validators
    6. Dependency Injection
    7. Summary
  4. Chapter 3: Introduction to Spring MVC
    1. The Benefits of Spring MVC
    2. Spring MVC DispatcherServlet
    3. The Controller Interface
    4. Your First Spring MVC Application
    5. The View Resolver
    6. Summary
  5. Chapter 4: Annotation-Based Controllers
    1. Spring MVC Annotation Types
    2. Writing Request-Handling Methods
    3. Using An Annotation-Based Controller
    4. Dependency Injection with @Autowired and @Service
    5. Redirect and Flash Attributes
    6. Request Parameters and Path Variables
    7. @ModelAttribute
    8. Summary
  6. Chapter 5: Data Binding and the Form Tag Library
    1. Data Binding Overview
    2. The Form Tag Library
    3. Data Binding Example
    4. Summary
  7. Chapter 6: Converters and Formatters
    1. Converters
    2. Formatters
    3. Choosing Between Converters and Formatters
    4. Summary
  8. Chapter 7: Validators
    1. Validation Overview
    2. Spring Validators
    3. The ValidationUtils Class
    4. A Spring Validator Example
    5. JSR 303 Validation
    6. A JSR 303 Validator Example
    7. Summary
  9. Chapter 8: The Expression Language
    1. A Brief History of the Expression Language
    2. The Expression Language Syntax
    3. Accessing JavaBeans
    4. EL Implicit Objects
    5. Using Other EL Operators
    6. Referencing Static Fields and Methods
    7. Creating Sets, Lists and Maps
    8. Accessing List Elements and Map Entries
    9. Manipulating Collections
    10. Formatting Collections
    11. Formatting Numbers
    12. Formatting Dates
    13. Configuring the EL in JSP 2.0 and Later Versions
    14. Summary
  10. Chapter 9: JSTL
    1. Downloading JSTL
    2. JSTL Libraries
    3. General-Purpose Actions
    4. Conditional Actions
    5. Iterator Actions
    6. Formatting Actions
    7. Functions
    8. Summary
  11. Chapter 10: Internationalization
    1. Locales
    2. Internationalizing Spring MVC Applications
    3. Summary
  12. Chapter 11: File Upload
    1. Client Side Programming
    2. The MultipartFile Interface
    3. File Upload with Commons FileUpload
    4. File Upload with Servlet 3 or Later
    5. Upload Clients
    6. Summary
  13. Chapter 12: File Download
    1. File Download Overview
    2. Example 1: Hiding A Resource
    3. Example 2: Preventing Cross-Referencing
    4. Summary
  14. Chapter 13: Testing Your Application
    1. Unit Testing Overview
    2. State Testing vs. Behavior Testing
    3. Using JUnit
    4. Using Test Doubles
    5. Unit Testing Spring MVC Controllers
    6. Integration Testing with Spring MVC Test
    7. Changing the Web Root in Integration Testing
    8. Summary
  15. Appendix A: Tomcat
    1. Downloading and Configuring Tomcat
    2. Starting and Stopping Tomcat
    3. Defining A Context
    4. Defining A Resource
    5. Installing TLS Certificates
  16. Appendix B: Using Spring Tool Suite with Maven
    1. Installing the Spring Tool Suite (STS)
    2. Creating a Spring MVC Application
    3. Selecting the Java Version
    4. Creating An index.html File
    5. Updating the Project
    6. Running the Application
  17. Appendix C: The Servlet API
    1. Servlet API Overview
    2. Servlet
    3. Writing A Basic Servlet Application
    4. ServletRequest
    5. ServletResponse
    6. ServletConfig
    7. ServletContext
    8. GenericServlet
    9. HTTP Servlets
    10. HttpServletRequest
    11. Working with HTML Forms
    12. Using the Deployment Descriptor
    13. Summary
  18. Appendix D: JavaServer Pages
    1. An Overview of JSP
    2. Comments
    3. Implicit Objects
    4. Directives
    5. Scripting Elements
    6. Summary
  19. Appendix E: Deployment
    1. Deployment Descriptor Overview
    2. Deployment
    3. Web Fragments
    4. Summary