REST笔记

GET,PUT,DELETE,POST,HEAD,OPTIONS
只有POST不是idempotent其它全是。
URI格式
scheme://host:port/path?queryString#fragment
  
MIME的格式
type/subtype;name=value;name=value比如:
text/plain
text/html
text/html; charset=iso-8859-1

no client session data on server side.
可以使用http cache

Create
PUT orders/123需要指定id, 响应201 Created.
POST /orders, 无需ID,响应201 Created.,并在header['Location']中指出这个新建的order的URI
HTTP/1.1 201 Created
Content-Type: application/xml
Location: http://example.com/orders/233


Update

PUT orders/123 响应"200 OK" with response body  OR "204 No Content" without response body

DELETE
同UPDATE

P31所有的入参都必须annotated,只允许有一个入参不被annotated,它代表HTTP Request message body

接口CustomerResource(包含所有的annotation),实现CustomerResourceService(no annotation)

AbstractCustomerResource(包含所有方法annotation),实现CustomerResource(仅包含类上的Annotation->@Path)

P39页继承自Application我们的代码是如何实现的?getClasses, getSingletons

P40写个JAXRS客户端测试REST服务。

@HttpMethod(HttpMethod.GET)
@HttpMethod("LOCK")

P48 @Path 匹配优先级:更长字面量》更多template expression > 更少default template expression
{id} 这是default template expression, {id : .+}这是nondefault template express,  customers这是字面量, {...}这是template expression.

P49 @Path中的特殊字符 ,;:$&+=?/\[]@ 如若出现,JAXRS将会自动转义=> %加上对应的ASCII code(2-digit hexadecimal number)

P50 Matrix Parameters形如:
http://example.cars.com/mercedes/e55;color=black/2006

;color=black就是,它和query parameter不同,它是修饰URI segment(e55)的,你可以放在请求中,但是JAXRS会无视它的存在。


你可能感兴趣的:(REST笔记)