Spring学习笔记:MVC Controller的RequestMapping

1.可用注释:@RequestMapping @RequestParam @ModelAttribute,可用于Servlet MVC 和Portlet MVC
2.自动检测:
<context:component-scan base-package="org.springframework.samples.petclinic.web"/>
3.支持URI template
@RequestMapping(value="/owners/{ownerId}", method=RequestMethod.GET)
public String findOwner(@PathVariable String ownerId, Model model) {
Owner owner = ownerService.findOwner(ownerId);
model.addAttribute("owner", owner);
return "displayOwner";
}

3.@RequestMapping也支持Ant-style path patterns,
支持条件参数
@RequestMapping(value = "/pets/{petId}", params="myParam=myValue")
支持header
@RequestMapping(value = "/pets", method = RequestMethod.POST, headers="content-type=text/*")

你可能感兴趣的:(spring,mvc,ant,servlet)