Mar*_*eon 29 java rest web-services jersey restlet
在Java中实现客户端和服务器REST框架的最佳框架是什么?我一直在努力寻找一个易于使用的解决方案.
更新:Jersey和Restlet看起来都是不错的选择.我们可能会使用Restlet但我们会尝试两者.
Dro*_*roo 24
泽西岛对两者都很容易.要编写Web服务,请使用注释:
@Path("/helloworld")
public class HelloWorldResource {
// The Java method will process HTTP GET requests
@GET
// The Java method will produce content identified by the MIME Media
// type "text/plain"
@Produces("text/plain")
public String helloWorld() {
// Return some cliched textual content
return "Hello World";
}
}
Run Code Online (Sandbox Code Playgroud)
对于客户:
Client client = Client.create();
WebResource webResource = client.resource("http://localhost:8080/helloworld");
String s = webResource.get(String.class);
System.out.println(s); // prints Hello World
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
30162 次 |
| 最近记录: |