@PathParam:(//)
例如:Postman请求格式 为 http://localhost:8080/ct/customer/list/1/10
@GET
@Path("/list/{page}/{pageSize}")
public Pageable<Customer> listPage(@PathParam("page") int page,@PathParam("pageSize") int pageSize) {
return this.getService().getAll(this.getQueryFilter(),page,pageSize);
}
@PathVariable(??)
例如:Postman请求格式 http://localhost:8080/ct/customer/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(??)
例如:Postman请求格式 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){
...
}
@RequestParam
和 @PathVariable
注解是用于从request中接收请求的,两个都可以接收参数,关键点不同的是@RequestParam
是从request里面拿取值,而 @PathVariable
是从一个URI模板里面来填充。。
@PathParam这个注解是和spring的pathVariable是一样的,也是基于模板的,但是这个是jboss包下面的一个实现,上面的是spring的一个实现,都要导包