https://blog.youkuaiyun.com/zianY/article/details/80541311
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.youkuaiyun.com/zianY/article/details/80541311 </div>
<link rel="stylesheet" href="https://csdnimg.cn/release/phoenix/template/css/ck_htmledit_views-3019150162.css">
<link rel="stylesheet" href="https://csdnimg.cn/release/phoenix/template/css/ck_htmledit_views-3019150162.css">
<div class="htmledit_views" id="content_views">
<p style="margin:10px auto;color:rgb(51,51,51);font-family:Verdana, Arial, Helvetica, sans-serif;font-size:14px;background-color:rgb(255,255,255);">@RequestMapping 和 @GetMapping @PostMapping 区别</p><p style="margin:10px auto;color:rgb(51,51,51);font-family:Verdana, Arial, Helvetica, sans-serif;font-size:14px;background-color:rgb(255,255,255);"></p><p><br></p><p>新的项目 在controller中 方法上面 没有RequestMapping 写的是 GetMapping 一时间不知道是什么意思 查了一下 发现是一个组合注解</p><div style="padding:0px;margin:0px;color:rgb(51,51,51);font-size:14px;background-color:rgb(255,255,255);white-space:pre-wrap;line-height:1.875;"> Spring4.3中引进了{@GetMapping、@PostMapping、@PutMapping、@DeleteMapping、@PatchMapping} 来帮助简化常用的HTTP方法的映射 并更好地表达被注解方法的语义 </div><div style="padding:0px;margin:0px;color:rgb(51,51,51);font-size:14px;background-color:rgb(255,255,255);white-space:pre-wrap;line-height:1.875;"> 该注解将HTTP Get 映射到 特定的处理方法上</div><p style="margin:10px auto;color:rgb(51,51,51);font-family:Verdana, Arial, Helvetica, sans-serif;font-size:14px;background-color:rgb(255,255,255);"><br></p><p style="margin:10px auto;color:rgb(51,51,51);font-family:Verdana, Arial, Helvetica, sans-serif;font-size:14px;background-color:rgb(255,255,255);"><br></p><p style="margin:10px auto;color:rgb(51,51,51);font-family:Verdana, Arial, Helvetica, sans-serif;font-size:14px;background-color:rgb(255,255,255);">@GetMapping是一个组合注解 是@RequestMapping(method = RequestMethod.GET)的缩写</p><p style="margin:10px auto;color:rgb(51,51,51);font-family:Verdana, Arial, Helvetica, sans-serif;font-size:14px;background-color:rgb(255,255,255);"> </p><p style="margin:10px auto;color:rgb(51,51,51);font-family:Verdana, Arial, Helvetica, sans-serif;font-size:14px;background-color:rgb(255,255,255);">@PostMapping是一个组合注解 是@RequestMapping(method = RequestMethod.POST)的缩写</p><p></p><p><br></p><p></p><p></p> </div>
</div>