@RequestMapping注解的做用是对用户的请求映射到指定的控制器或方法,因此该注解能够用来修饰类和方法,在RequestMapping的源码中看到这么一句话数组
@Target({ElementType.METHOD, ElementType.TYPE})
也一样能够说明该注解所修饰的类型。ruby
在RequestMapping修饰方法时,能够有以下四个参数markdown
其中,value为默认参数,表示用户请求的url,若是只用到该参数,则不须要写参数名,如app
@RequestMapping("/helloworld")
method用来过滤用户请求的方法,即post或get,如post
@RequestMapping(value = "/helloworld",method = RequestMethod.GET)
params为请求携带的参数,该项可包括多个参数,参数之间为“与”url
@RequestMapping(value = "/helloworld",params = "username,password")
也能够用数组的形式表示spa
@RequestMapping(value = "/helloworld",params = {"username=admin", "password"})
heads为http请求头中携带的内容,如Accept-Encoding等,具体方法同paramscode
未完。。。get