区别如下下:

 @GetMapping用于将HTTP get请求映射到特定处理程序的方法注解
具体来说,@GetMapping是一个组合注解,是@RequestMapping(method = RequestMethod.GET)的缩写。

@PostMapping用于将HTTP post请求映射到特定处理程序的方法注解
具体来说,@PostMapping是一个组合注解,是@RequestMapping(method = RequestMethod.POST)的缩写

检验第一个使用的是GetMapping,第二个使用的是@RequestMapping:

 @GetMapping("/getRule")
    public Rule getRule(){
        Rule rule=new Rule(" @GetMapping","404");
        return rule;
    }

    @RequestMapping(method = RequestMethod.GET  ,value = "/getRule2")
    public Rule getRule2(){
        Rule rule=new Rule("@RequestMapping(method = RequestMethod.GET ","404");
        return rule;
    }

使用的是GetMapping

使用的是@RequestMapping

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐