Chapter 5. Controllers—handling HTTP requests

This chapter covers

  • How to use controllers
  • Using action methods and results
  • Using routing to wire URLs to action methods
  • Composing actions with interceptors
  • Using the different scopes

In this chapter we’ll explain in detail one of the key concepts of the Play framework MVC paradigm: the controller. We’ll take a closer look at our warehouse web application and at the same time explain how interaction with a web client works in Play.

We’ll start by explaining controllers, and from there we’ll examine action methods and how we can return results to web clients. We’ll then see how to use routes to link HTTP requests to a controller’s action method. After that, we’ll look at what interceptors ...

Get Play for Java now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.