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的接收參數方式。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章