October 2017
Intermediate to advanced
396 pages
10h 2m
English
The previously defined HomeController class has only one handler method, and this method is annotated with the @RequestMapping annotation. Here, I have used two attributes of this annotation--one is value to map the HTTP request to the / pattern, and the other attribute is a method for supporting the HTTP GET method. We can define multiple URL mappings with one handler method. Let's see this in the following code snippet:
@Controller
public class HomeController {
@RequestMapping(value = {"/", "/index"}, method = RequestMethod.GET)
public String home (){
return "home";
}
}
In the preceding code, the @RequestMapping annotation has an array of string values for the value attribute of this annotation. Now, ...
Read now
Unlock full access