SpringBoot常⽤注解@RestController@GetMapping@Resq。。
1、@Controller
spring framework guru
@Controller ⽤来响应页⾯,表⽰当前的类为控制器。
2、@RestController
@RestController 是@ResponseBody和@Controller的结合
表明当前类是控制器且返回的是⼀组数据,不是页⾯
3、@Autowired
这个注解的作⽤是将其他的类,接⼝引⼊,类似于之前的类的初始化等,⽤这个注解,类中或接⼝的⽅法就可以直接调⽤了。
4、@RequestMapping
当前台界⾯调⽤Controller处理数据时候告诉控制器怎么操作
作⽤:URL映射。
5、@GetMapping
@RequestMapping(method = RequestMethod.GET)的简写
作⽤:对应查询,表明是⼀个查询URL映射
6、@PostMapping
@RequestMapping(method = RequestMethod.POST)的简写
作⽤:对应增加,表明是⼀个增加URL映射
7、@PutMapping
@RequestMapping(method = RequestMethod.PUT)的简写
作⽤:对应更新,表明是⼀个更新URL映射
8、@DeleteMapping
@RequestMapping(method = RequestMethod.DELETE)的简写
作⽤:对应删除,表明是⼀个删除URL映射

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。