In this section, you will learn about defining new handler methods using @RequestMapping annotation.
Handler methods are used to handle the requests which is passed to these method through @RequestMapping annotation. Or in other words, we can say that "@RequestMapping annotation is used to map the requested URL to the associated method to handle the request".
Handler methods have very flexible signatures. The arguments order can be interchanged frequently except BindingResult argument.
Given below the supported argument types of handler methods :
Given below sequence is invalid :
@RequestMapping(method = RequestMethod.POST)
public String submitProcessing(@ModelAttribute("employee") Employee employee,
Model model, BindingResult result) {
............
}
The ordering of BindingResult and @ModelAttribute must be as follows :
@RequestMapping(method = RequestMethod.POST)
public String submitProcessing(@ModelAttribute("employee") Employee employee,
BindingResult result, Model model) {
.........
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: Defining handler methods using @RequestMapping annotation
Post your Comment