jax-rs(Java API for RESTful Web Services)实践教程 之二 —— get/post/put/delete/head

来源:互联网 发布:js获取元素属性的办法 编辑:程序博客网 时间:2024/05/21 22:54

转载请注明出处,谢谢 http://blog.csdn.net/exsuns

 

 

新建一个web工程:

 

新建类com.Hello.java ,内容如下

 

 

 

 

 

最后部署到服务器,并启动

 

 

客户端:

 

 

打开客户端进行测试,就会在出现结果。

get/post/delete/put 都会出现结果

不过head有可能不会出现

 

关于head请求,sun有一句话

By default the JAX-RS runtime will automatically support the methodsHEAD, if not explicitly implemented. For HEAD the runtimewill invoke the implemented GET method (if present) and ignore theresponse entity (if set).

 

默认请况下 jax-rs运行时会自动支持head和options请求,如果没有明确实现,head运行时会调用get,同时会忽略response写出