Spring boot下的Spring mvc 和之前的Spring mvc使用时完全一样:

@Controller 即为Spring mvc的注解,处理http请求;

@RestController

  • Spring4后新增注解
  • 是@Controller与@ResponseBody的组合注解
  • 用于返回字符串货json数据

RestController注解举例:

新建一个User类

springboot学习总结三(Spring boot下的springmvc)

springboot学习总结三(Spring boot下的springmvc)

运行结果:

springboot学习总结三(Spring boot下的springmvc)

@GetMapping @RequestMapping与Get请求方法的结合

springboot学习总结三(Spring boot下的springmvc)

@PostMapping @RequestMapping与Post请求方法的结合

@PutMapping @RequestMapping与Put请求方法的结合

@DeleteMapping @RequestMapping与Delete请求方法的结合

 

相关文章:

  • 2021-12-03
  • 2021-09-12
  • 2021-08-17
  • 2021-09-18
  • 2021-07-13
  • 2021-07-21
猜你喜欢
  • 2021-07-02
  • 2022-01-05
  • 2021-12-28
  • 2021-10-10
  • 2021-05-17
  • 2021-09-17
相关资源
相似解决方案