@PostMapping,@GetMapping,@PutMapping是什么,有什么区别、常用注解总结

446 阅读1分钟
  • @GetMapping是一个组合注解,是@RequestMapping(method = RequestMethod.GET)的缩写。该注解将HTTP Get 映射到特定的处理方法上。

  • 同理PostMapping也是一个组合注解,是@RequestMapping(method = RequestMethod.POST)的缩写

@PostMapping,@GetMapping最主要的区别是

@PostMapping一般处理对象的findUser

@GetMapping一般处理单个id,比如findbyId

@PutMapper一般用在编辑,也可以只用上面两种

常用注解总结

一级:频繁常用
@RequestMapping
@GetMapping
@PostMapping
@RestController
@Service
@Mapper
@Repository
@Slf4j
@Compent
@ResponseBody
@PathVariable
@RequestParam
@Bean
@Before
@After
@Transactional
@Configuration
@Resource
@Autowired
@SpringBootApplication
@SpringBootTest
@Test
@Override
@Value
在这里插入图片描述

二级:经常用
@PutMapping
@DeleteMapping
@MapperScan

三级:一般用
@Import 引用
@CofigurationProperties
@EnableConfiguratioProperties

四级:很少用
@Mapping

文章知识点与官方知识档案匹配,可进一步学习相关知识

本文使用 文章同步助手 同步