开发者

Spring MVC Web PetClinic Tutorial?

开发者 https://www.devze.com 2022-12-24 05:50 出处:网络
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:

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 开发者_如何学C(like spring-security has) that would be very helpful. Thanks.


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消