文件名称:通过URL限定:绑定{xxx}中的值-SpringMVC学习
文件大小:1.44MB
文件格式:PPT
更新时间:2024-05-16 03:15:28
SpringMVC
通过URL限定:绑定{xxx}中的值 @RequestMapping("/{userId}") public ModelAndView showDetail(@PathVariable("userId") String userId){ ModelAndView mav = new ModelAndView(); mav.setViewName("user/showDetail"); mav.addObject("user", userService.getUserById(userId)); return mav; } @Controller @RequestMapping("/owners/{ownerId}") public class RelativePathUriTemplateController { @RequestMapping("/pets/{petId}") public void findPet(@PathVariable String ownerId, @PathVariable String petId, Model model) { … } }