SpringMVC GET请求类型 接收参数的方式

 
 
1,@PathVariable 方式接收URI参数。URI如:http://localhost:8080/MyApp/123/Jack/
    @RequestMapping(value="user/{userId}/{userName}",method=RequestMethod.GET)
    public String printMessage1(@PathVariable("userId") String id,@PathVariable("userName") String name) {
 
}

    @GetMapping("user/{userId}/{userName}")
    public String printMessage1(@PathVariable("userId") String id,@PathVariable("userName") String name) {
 
}
2,@RequestParam的方式接收URI参数。 URI如:http://localhost:8080/MyApp?date=12-05-2013
          @GetMapping
    public String printMessage1(@RequestParam("date") String theDate) {
 
 
}
 
ps:@RequestBody不属于GET的接收参数方式。
发布了25 篇原创文章 · 获赞 4 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/qq_41570691/article/details/80884663