Reputation: 24679
I have a Spring MVC form in jsp and I am having trouble getting the controller method invoked.
Can someone please explain to me the mechanism whereby Spring MVC performs controller method execution?
Upvotes: 0
Views: 204
Reputation: 896
If you are using Spring 3 and annotations (recommended way of implementing controllers), the @RequestMapping(value="exampleMapping.do") specifies the method that will be executed. Here is an example:
@RequestMapping("/exampleMapping.do")
public String anExample(Model model) {
// do some stuff
return "someView";
}
So in this case, if your form submit target is exampleMapping.do, the method anExample will execute and return someView (which will resolve to your view folder containing a jsp named someView.jsp if you have your view resolver configured correctly).
Upvotes: 1