handled all exception messages inside Spring config

This commit is contained in:
Mic 2013-01-10 16:12:50 +08:00
parent aeeeace8a2
commit 58d82e461a
3 changed files with 18 additions and 19 deletions

View file

@ -5,6 +5,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.samples.petclinic.Clinic;
import org.springframework.samples.petclinic.Vets;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
@ -54,10 +55,11 @@ public class ClinicController {
* @return a ModelMap with the model attributes for the view
*/
@RequestMapping("/vets")
public ModelMap vetsHandler() {
public String showVetList(Model model) {
Vets vets = new Vets();
vets.getVetList().addAll(this.clinic.getVets());
return new ModelMap(vets);
model.addAttribute("vets", vets);
return "vets";
}
/**
@ -67,7 +69,7 @@ public class ClinicController {
* @return a ModelMap with the model attributes for the view
*/
@RequestMapping("/owners/{ownerId}")
public ModelAndView ownerHandler(@PathVariable("ownerId") int ownerId) {
public ModelAndView showOwner(@PathVariable("ownerId") int ownerId) {
ModelAndView mav = new ModelAndView("owners/show");
mav.addObject(this.clinic.loadOwner(ownerId));
return mav;