O'Reilly logo

Hands-On High Performance with Spring 5 by Dinesh Radadiya, Prashant Goswami, Pritesh Shah, Subhash Shah, Chintan Mehta

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating a controller

Now, let's create a controller class to map the /home request, as follows:

package com.packt.springhighperformance.ch4.controller;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.RequestMapping;@Controllerpublic class BankController {  @RequestMapping(value = "/home")  public String home() {    return "home";  }}

In the preceding code, @Controller defines a Spring MVC controller that contains request mappings. The @RequestMapping(value = "home") object defines a mapping URL, /home, to a method, home(). So, when the browser hits a /home request, it executes the home() method.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required