java-ee 删除方法
示例
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Response;
@Path("hello")
public class HelloWorldResource {
private String message = "您好StackOverflow!";
@GET
@Produces("text/plain")
public String getHello() {
return message;
}
@DELETE
public Response deleteMessage() {
message = null;
return Response.noContent().build();
}
}卷曲地使用它:
$ curl http://localhost/hello 您好StackOverflow! $ curl -X "DELETE" http://localhost/hello $ curl http://localhost/hello null