@Param用在数据层
@RequestParam,@PathVariable用在控制器层
其中,
要访问http://localhost:8080/springmvc/hello/101?param1=10¶m2=20
public String getDetails{
@RequestParam(value="param1", required=true) String param1,
@RequestParam(value="param2", required=false) String param2){
}
要访问http://localhost:8080/springmvc/hello/101?param1=10¶m2=20
@RequestMapping("/hello/{id}")
public String getDetails(@PathVariable(value="id") String id,
@RequestParam(value="param1", required=true) String param1,
@RequestParam(value="param2", required=false) String param2){
}
总结: ? 后面的用 @RequestParam,
rest风格的(/后面的)用@PathVariable.