SpringBoot获取url参数的方式

SpringBoot获取url参数的方式

方式一

	@RequestMapping(value = "/select",method = RequestMethod.GET)
    public void selectUserById(@RequestParam("id") Integer id){
    
    
        System.out.println(id);	
    }
	//http://localhost:8080/select?id=1

方式二

   @RequestMapping(value = "/select/{id}",method = RequestMethod.GET)
    public void selectUserById(@PathVariable("id") Integer id){
    
    
        System.out.println(id);
    }
    //http://localhost:8080/select/1

猜你喜欢

转载自blog.csdn.net/m0_53294821/article/details/114527771