@RequestParam和@PathVariable参数注入的时候区别

@RequestParam和@PathVariable参数注入的时候区别,第1张

@RequestParam和@PathVariable参数注入的时候区别

//游览访问路径:http://localhost:8080/t1?id=1
@RequestMapping("/t1")
public String t1(@RequestParam(“id”) int id){ //@RequestParam是必须要在游览器中访问的时候,在路径上加上 id
return “success: :”+id;
}

//游览器访问格式::http://localhost:8080/t2/1
@GetMapping("/t2/{id}")
public String tt(@PathVariable("id") int id){
    return "Sussecc::"+id ;
}

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5638121.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-16
下一篇 2022-12-16

发表评论

登录后才能评论

评论列表(0条)

保存