1. 程式人生 > >java常見註釋整理

java常見註釋整理

1. @component

可以在實體類(pojo)上註釋,等同於注入spring的bean物件


2.@PathVariable

url:localhost:8080/hello/666

@RequestMapping(value = "/hello/{id}" )
public String say(@PathVariable("id") String id){
    return id;
}

3.@RequstParam

url:localhost:8080/hello?id=666

@RequestMapping(value = "/hello" 
) public String say(@RequestParam("id") String id){ return id; }