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;

@Controller
public 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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset