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的接收参数方式。