8 Implementing web apps with Spring Boot and Spring MVC

 

This chapter covers

  • Using a template engine to implement dynamic views
  • Sending data from client to server through HTTP requests
  • Using GET and POST HTTP methods for your HTTP requests

In chapter 7, we made progress in understanding how to use Spring to write web apps. We’ve discussed a web app’s components, the dependencies a web app needs, and the Spring MVC architecture. We even wrote a first web app to prove all these components work together.

In this chapter, we’ll take a step further and implement some capabilities you’ll find in any modern web app. We start with implementing pages whose content changes according to how your app processes the data for specific requests. Today we rarely see static pages on websites. You probably think, “There has to be a way to decide what content to add on the pages before delivering the HTTP response back to the browser.” There are ways you can do this!

In section 8.1, we’ll implement dynamic views using template engines. A template engine is a dependency that allows you to easily get and display variable data the controller sends. We’ll demonstrate how the template engine works in an example after reviewing the Spring MVC flow.

In section 8.2, you’ll learn how to send data from the client to the server through the HTTP request. We’ll use that data in the controller’s method and create the dynamic content on the view.

8.1 Implementing web apps with a dynamic view

8.1.1 Getting data on the HTTP request

8.1.2 Using request parameters to send data from client to server

8.1.3 Using path variables to send data from client to server

8.2 Using the GET and POST HTTP methods

Summary

sitemap