SpringBoot : Controller的使用

用到的以**解:

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

 

 

@PathVariable 获取 url 中的数据
@RequestParam 获取请求参数的值
@GetMapping 组合注解

 

@PathVariable 获取url 中的数据

 

SpringBoot : Controller的使用

 

有图注意书写格式。

 

SpringBoot : Controller的使用

 

SpringBoot : Controller的使用

 

传统的获取数据的格式。

 

SpringBoot : Controller的使用

 

结果。

 

SpringBoot : Controller的使用

 

设置默认属性。

 

SpringBoot : Controller的使用

 

输出结果。

 

SpringBoot : Controller的使用

 

@GetMapping()

 

SpringBoot : Controller的使用

未完待续...