利用IDEA构建springboot应用-Controller的使用

                                                                             Controller的使用

@Controller 处理http请求 
 @RestController  Spring4之后新加的注解,原来返回json需要@ResponseBody配合@Controller
 @RequestMapping 配置url映射 (路径)

@Controller要配合模板使用  (了解下前后端分离)

                                                                            如何获取url里面的参数

@PathVariable 获取url中的数据
@RequestParam 获取请求参数的值

@GetMapping

组合注解

@PathVariable

@RequestParam

默认值

 

简化@RequestMapping  (采用组合注解

@GetMapping
..........

)

猜你喜欢

转载自www.cnblogs.com/tanlei-sxs/p/9716357.html