實驗了一上午,終于可以使用jersey輸出cookie了.
@POST
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@SecureValid
public Response getUserPost(@Context UriInfo context) {
URI createdUri = context.getAbsolutePath();
NewCookie nc = new NewCookie("token","tokencode1","/","","",-1,false);
return Response.created(createdUri).cookie(nc).build();
}
這樣建立完cookie後,效果如下.