* RESTful WebService入门
* @author leizhimin 2009-11-18 16:42:43
*/
package example;
import com.sun.jersey.api.container.httpserver.HttpServerFactory;
import com.sun.net.httpserver.HttpServer;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import java.io.IOException;
//指定URI
@Path("/helloworld")
public class HelloWorld {
//处理HTTP的GET请求
@GET
// 处理请求反馈的内容格式为"text/plain"
@Produces("text/plain")
public String getClichedMessage() {
return "Hello World!";
}
public static void main(String[] args) throws IOException {
//创建RESTful WebService服务
HttpServer server = HttpServerFactory.create("http://192.168.14.117:9999/");
//启动服务,这会导致新开一个线程
server.start();
//输出服务的一些提示信息到控制台
System.out.println("RESTful WebService服务已经启动");
System.out.println("服务访问地址: http://192.168.14.117:9999/helloworld");
}
}
信息: Scanning for root resource and provider classes in the paths:
D:\jdk16\jre\lib\alt-rt.jar
D:\jdk16\jre\lib\charsets.jar
D:\jdk16\jre\lib\deploy.jar
D:\jdk16\jre\lib\javaws.jar
D:\jdk16\jre\lib\jce.jar
D:\jdk16\jre\lib\jsse.jar
D:\jdk16\jre\lib\management-agent.jar
D:\jdk16\jre\lib\plugin.jar
D:\jdk16\jre\lib\resources.jar
D:\jdk16\jre\lib\rt.jar
D:\jdk16\jre\lib\ext\dnsns.jar
D:\jdk16\jre\lib\ext\localedata.jar
D:\jdk16\jre\lib\ext\sunjce_provider.jar
D:\jdk16\jre\lib\ext\sunmscapi.jar
D:\jdk16\jre\lib\ext\sunpkcs11.jar
D:\netwideo\restws\out\production\restws
D:\IDEA8\lib\javaee.jar
D:\netwideo\restws\lib\mail-1.4.jar
D:\netwideo\restws\lib\asm-3.1.jar
D:\netwideo\restws\lib\wadl2java.jar
D:\netwideo\restws\lib\jettison-1.0.1.jar
D:\netwideo\restws\lib\grizzly-servlet-webserver-1.8.6.4.jar
D:\netwideo\restws\lib\wadl-core.jar
D:\netwideo\restws\lib\localizer.jar
D:\netwideo\restws\lib\jdom-1.0.jar
D:\netwideo\restws\lib\jsr311-api-1.0.jar
D:\netwideo\restws\lib\stax-api-1.0-2.jar
D:\netwideo\restws\lib\persistence-api-1.0.2.jar
D:\netwideo\restws\lib\jaxb-api-2.1.jar
D:\netwideo\restws\lib\wadl-cmdline.jar
D:\netwideo\restws\lib\http-20070405.jar
D:\netwideo\restws\lib\rome-0.9.jar
D:\netwideo\restws\lib\activation-1.1.jar
D:\netwideo\restws\lib\jaxb-impl-2.1.10.jar
D:\netwideo\restws\lib\jersey-bundle-1.0.3.jar
D:\netwideo\restws\lib\jackson-lgpl-0.9.4.jar
D:\netwideo\restws\lib\FastInfoset-1.2.2.jar
D:\netwideo\restws\lib\jaxb-xjc.jar
D:\IDEA8\lib\idea_rt.jar
2009-11-18 17:25:46 com.sun.jersey.api.core.ClasspathResourceConfig init
信息: Root resource classes found:
class example.HelloWorld
2009-11-18 17:25:46 com.sun.jersey.api.core.ClasspathResourceConfig init
信息: Provider classes found:
RESTful WebService服务已经启动
服务访问地址: http://192.168.14.117:9999/helloworld
asm-3.1.jar
FastInfoset-1.2.2.jar
grizzly-servlet-webserver-1.8.6.4.jar
http-20070405.jar
jackson-lgpl-0.9.4.jar
jaxb-api-2.1.jar
jaxb-impl-2.1.10.jar
jaxb-xjc.jar
jdom-1.0.jar
jersey-bundle-1.0.3.jar
jettison-1.0.1.jar
jsr311-api-1.0.jar
mail-1.4.jar
localizer.jar
persistence-api-1.0.2.jar
rome-0.9.jar
stax-api-1.0-2.jar
wadl-core.jar
wadl-cmdline.jar
wadl2java.jar