chapter eight

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

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

Now we’ll take a step further and implement some capabilities you’ll find in any modern web app. Today, we rarely see static pages on websites. You probably think, “There has to be a way to decide what content to add to the pages before delivering the HTTP response back to the browser.” There are ways you can do this!

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

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

8.3 Questions

8.4 Summary