java常见注释整理

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_37279783/article/details/79984646

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;
}



猜你喜欢

转载自blog.csdn.net/qq_37279783/article/details/79984646
今日推荐