Reputation: 12470
Is there a tutorial that goes along with the PetClinic application? I have been trying to find one, but google is not helping me today. Specifically, I dont understand things like:
@Autowired - what does that even mean?
@RequestMapping(method = RequestMethod.GET)
public String setupForm(@RequestParam("petId") int petId, ModelMap model) {
Pet pet = this.clinic.loadPet(petId);
model.addAttribute("pet", pet);
return "petForm";
}
How can a request return just a string? Shouldnt it need to return some sort of ModelAndView? Or does the application somehow redirect to whatever is returned?
A lot of confusing concepts - if there is a tutorial, or video (like spring-security has) that would be very helpful. Thanks.
Upvotes: 1
Views: 1860
Reputation: 20993
It is returning the exact name of the view, so you could expect this to redirect you to the view located at /WEB-INF/jsp/petForm.jsp which will have access to the pet model
Upvotes: 0
Reputation: 73484
Autowired is Dependency injection. It creates beans for you and sets them.
In this example the controller is returning a String that is the name of the view. It's basically the same thing as
return new ModelAndView("petForm");
It could map to something else or it could be as simple as returning petForm.jsp. Depends on the View Resolver.
Upvotes: 1