天天看點

spring-web之@RequestParam,@ResponseBody,@RequestParam,@PathVariable

@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;
     }

}      

繼續閱讀