SpringMVC中RequestMapping注解类的使用

1、在springMVC中开发controller控制类,使用@Controller注解,并在springMVC配置文件中进行扫描配置

2、在controller控制器类中使用@RequestMapping注解来注解类和方法,以实现在RequestMapping中注入对该类和方法的请求的路径。在controller类中可以在类上注解@RequestMapping也可以不注解,如果注解了,则请求路径为:类的注解路径/方法的注解路径 否则直接为方法的注解路径。

SpringMVC中RequestMapping注解类的使用

3、RequestMapping注解类的属性:分别有value、method、cousumes、produces、params、header

value:     指定请求的实际地址,指定的地址可以是URI Template 模式(后面将会说明);

method:  指定请求的method类型, GET、POST、PUT、DELETE等;

consumes: 指定处理请求的提交内容类型(Content-Type),例如application/json, text/html;

produces:    指定返回的内容类型,仅当request请求头中的(Accept)类型中包含该指定类型才返回;

params: 指定request中必须包含某些参数值是,才让该方法处理。

headers: 指定request中必须包含某些指定的header值,才能让该方法处理请求。

SpringMVC中RequestMapping注解类的使用SpringMVC中RequestMapping注解类的使用SpringMVC中RequestMapping注解类的使用SpringMVC中RequestMapping注解类的使用SpringMVC中RequestMapping注解类的使用SpringMVC中RequestMapping注解类的使用