Spring MVC

Annotation 用法

@controller
@RequestMapping: 可以放在class上面 也可以放在method上面

  • @RequestMapping("/welcome")
  • @RequestMapping("/welcome/{countryName}/{name}")
  • @RequestMapping(value="/admissionForm.html", method=RequestMethod.GET)
  • @RequestMapping(value="/submitAdmissionForm.html", method=RequestMethod.POST)

@PathVariable

  • @PathVariable("name") String name
  • @PathVariable Map<String, String>这种方法是用来处理当传入很多variable的情况, 但是如果使用这种方法必须要在spring-dispatcher-servlet.xml文件中加入<mvc:annotation-driven />