@ResponseBody
@see
@RequestParam
RequestParam 是获取的uri中的成对存在的map的key和value
@PathVariable
@pathVariable 主要是针对的uri中path地址中的一个路径,本质上这个路径是一个变化的值:Variable 变化的
@PathParam
案例
源码地址
HelloController.sayHello
package com.gaoxinfu.demo.spring.web.controller;
import org.springframework.web.bind.annotation.*;
/**
* @Description:
* @Author: gaoxinfu
* @Date: 2021-01-11 17:06
*/
@RestController
public class HelloController {
@GetMapping(value = "/say/hello/{country}")
public String sayHello(@RequestParam("name") String name,
@RequestParam("age") String age,
@PathVariable("country") String country){
return "I come from "+ country+ ",hello,everyOne ,My Name is = " +name +",and My age is = " +age;
}
}