Reputation: 805
FYI. I did post this on the Spring Roo forum but no reply.
This is a very basic question from a newbie.
The question is concerning how the Controller knows to direct the menu link , such as the following from the petclinic example
<menu:item id="i_pet_new" messageCode="global_menu_new" url="/pets?form" z="SwmuMoL7UBbDU/gqHy+t5Tl0Ins="/>
My current understanding is that the
@RequestMapping("/pets")
@Controller
public class PetController {
}
Handles the url="/pet" portion but
How does the Controller know how to handle the remaining portion? The portion that says "?form" ?
I have done simple mvc projects before and I would have some code inside of the class PetController that would do something like:
@RequestMapping("/helloWorld")
public ModelAndView helloWorld() {
ModelAndView mav = new ModelAndView();
mav.setViewName("helloWorld");
mav.addObject("message", "Hello World!");
return mav;
}
In the current example there are no additional methods to handle the ModelAndView !
Thanks for the help.
Upvotes: 0
Views: 1548
Reputation: 52665
You will notice the file PetController_Roo_Controller.aj
created in the same folder as PetController.java
. This contains the relevant code to handle this. Specifically,
@RequestMapping(params = "form", method = RequestMethod.GET)
public String PetController.createForm(Model model) {
model.addAttribute("pet", new Pet());
return "pets/create";
}
Roo takes care of the CRUD operations for you.
Upvotes: 1