RESTFUL路径
来源:互联网 发布:arm处理器系列 知乎 编辑:程序博客网 时间:2024/06/05 05:58
method
get,put,post,delete,head
@GET
@Path("{id}")
public String getCustomer(@PathParam("id") int id) {
...
}
URL:example:
@Path("customers/{firstname}-{lastname}")
@Path("{id : \\d+}") //regular expressions
请求路径为,中间有附加的东西 /cars/mercedes/e55;color=black/2006
@Path("/cars/{make}")
public class CarResource {
@GET
@Path("/{model}/{year}")
@Produces("image/jpeg")
public Jpeg getPicture(@PathParam("make") String make,
@PathParam("model") PathSegment car, //简介调用 片段
@PathParam("year") String year) {
String carColor = car.getMatrixParameters().getFirst("color");
@GET
@Path("/{model}/{year}")
@Produces("image/jpeg")
public Jpeg getPicture(@PathParam("make") String make,
@PathParam("model") String model,
@MatrixParam("color") String color) { //直接调用片段
...
}
public class CarResource {
@GET
@Path("/{model}/{year}")
@Produces("image/jpeg")
public Jpeg getPicture(@Context UriInfo info) { //直接注入context 查看api进行相关调用
String make = info.getPathParameters().getFirst("make");
PathSegment model = info.getPathSegments().get(1);
String color = model.getMatrixParameters().getFirst("color");
...
}
}
查询
GET /customers?start=0&size=10
public String getCustomers(@QueryParam("start") int start,
@QueryParam("size") int size) {
查询
GET /customers?start=0&size=10
@Path("/customers")
public class CustomerResource {
@GET
@Produces("application/xml")
public String getCustomers(@Context UriInfo info) {
String start = info.getQueryParameters().getFirst("start");
String size = info.getQueryParameters().getFirst("size"); //上下文获取查询
...
}
}
表单接收
@Path("/customers")
public class CustomerResource {
@POST
public void createCustomer(@FormParam("firstname") String first,
@FormParam("lastname") String last) {
...
}
}
get,put,post,delete,head
@GET
@Path("{id}")
public String getCustomer(@PathParam("id") int id) {
...
}
URL:example:
@Path("customers/{firstname}-{lastname}")
@Path("{id : \\d+}") //regular expressions
请求路径为,中间有附加的东西 /cars/mercedes/e55;color=black/2006
@Path("/cars/{make}")
public class CarResource {
@GET
@Path("/{model}/{year}")
@Produces("image/jpeg")
public Jpeg getPicture(@PathParam("make") String make,
@PathParam("model") PathSegment car, //简介调用 片段
@PathParam("year") String year) {
String carColor = car.getMatrixParameters().getFirst("color");
@GET
@Path("/{model}/{year}")
@Produces("image/jpeg")
public Jpeg getPicture(@PathParam("make") String make,
@PathParam("model") String model,
@MatrixParam("color") String color) { //直接调用片段
...
}
public class CarResource {
@GET
@Path("/{model}/{year}")
@Produces("image/jpeg")
public Jpeg getPicture(@Context UriInfo info) { //直接注入context 查看api进行相关调用
String make = info.getPathParameters().getFirst("make");
PathSegment model = info.getPathSegments().get(1);
String color = model.getMatrixParameters().getFirst("color");
...
}
}
查询
GET /customers?start=0&size=10
public String getCustomers(@QueryParam("start") int start,
@QueryParam("size") int size) {
查询
GET /customers?start=0&size=10
@Path("/customers")
public class CustomerResource {
@GET
@Produces("application/xml")
public String getCustomers(@Context UriInfo info) {
String start = info.getQueryParameters().getFirst("start");
String size = info.getQueryParameters().getFirst("size"); //上下文获取查询
...
}
}
表单接收
@Path("/customers")
public class CustomerResource {
@POST
public void createCustomer(@FormParam("firstname") String first,
@FormParam("lastname") String last) {
...
}
}
- RESTFUL路径
- Spring MVC restful 路径小数点问题
- Spring MVC restful 路径小数点问题
- Restful
- restful
- RESTful
- restful
- RESTful
- RESTful
- RESTful
- RESTful
- RESTful
- RESTful
- RESTful
- RESTful
- restful
- Restful
- Restful
- vim黏贴代码格式混乱的解决方法
- Eclipse中的Ctrl+F8不工作
- javac编译Java工程
- mockito
- 网络工具的应用
- RESTFUL路径
- C++ QUICK REFERENCE
- design pattern tips
- test markdown-here chrome 插件
- Vim命令
- BIOS中断大全
- 陕西省妇幼预约系统分析
- DBMS_DISKGROUP, an internal ASM package
- 位级运算