原文地址:http://coolzhi.iteye.com/blog/588543
restful web services,相信对于大多数读者来说已经不是什么新鲜的名词,网上能搜到的资料也是汗牛充栋,数不胜数,故在此本人就不再赘述,仅提供若干参考网站,同时附件中也提供一些收集到的restful web services的学习资料,有兴趣的朋友可以下载来看一下。在这里我只是想简单说一下如何利用eclipse和tomcat如何快速实现restful web services的HelloWorld。接着下来我想通过不断的学习由浅入深形成一系列的文章。
第一步:新建web项目
在eclipse中新建一个Web Project即可,地球上的java开发者都知道怎么做的
第二步:集成restful web services
把附件中的lib.zip解压后的所有jar复制到项目的lib目录下,然后在web.xml里增加如下代码:
<servlet>
<servlet-name>JerseyServlet</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>JerseyServlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
第三步:新建HelloWorld类
package net.jackshow.test;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
@Path("/helloWorld")
public class HelloWorld {
@GET
@Produces(MediaType.TEXT_PLAIN)
public String helloWorld(){
String ret = "Hello World!";
return ret;
}
}
完成后把项目发布到tomcat,然后在浏览器中输入http://hostname:port/projectname/services/helloWorld(注:这里的hostname是指你的主机名,如localhost;port是tomcat的端口,如8080;projectname是指你第一步新建的项目名),浏览器上即打印出“Hello World!”
附:
restful web services的介绍:http://xingshaomin.iteye.com/blog/127224
java的restful web services的实现项目jersey官网:https://jersey.dev.java.net/
sun官网关于restful web services的介绍:http://java.sun.com/developer/technicalArticles/WebServices/restful/
分享到:
相关推荐
RESTful Web Services 中文版 高清 PDF 电子书
RESTful Java Web Services, Master core REST concepts and create RESTful web services in Java, Jose Sandoval, Copyright 2009 Packt Publishing
如Amazon的简单存储服务与Atom发布协议等 ·探讨各种流行编程语言的Web services客户端 ·展示如何用三种流行框架实现RESTful services —— Ruby on Rails、Restlet(基于Java)和Django(基于Python) ·关注实际...
RESTful Java Web Services (2009).pdf This book is for developers who want to code RESTful web services using the Java technology stack together with any of the frameworks Jersey's JAX-RS, Restlet's ...
Building RESTful Web Services with Spring 5 – Second Edition: Leverage the power of Spring 5.0, Java SE 9, and Spring Boot 2.0 Find out how to implement the REST architecture to build resilient ...
Java RESTful Web Service实战.pdf Java RESTful Web Service实战.pdf
Building RESTful Web Services with Java EE 8 is a comprehensive guide that will show you how to develop state-of-the-art RESTful web services with the latest Java EE 8 APIs. You will begin with an ...
RESTFUL_JAVA_WEB_SERVICES_THIRD_EDITION.pdf
Dropwizard is a Java development framework for RESTful Web Services. It was initially built by Yammer to be used as the base of their backend systems. Dropwizard is production-ready; it encapsulates ...
RESTful Java Web Services(2nd) 英文azw3 第2版 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请联系上传者或csdn删除
Representational State Transfer (REST) is a simple yet powerful ... This book, RESTful Java webservices, is a practical guide developing RESTful web services using JAX-RS and Jersey extension APIs.
Building RESTful Web Services with Java EE 8_Code 源码
RESTful webservices – Client API in Java - Jersey
包括这本书的英文版(相当清晰),中文版(较清晰),以及书上的源码 由于中文版太大,故只附上了下载地址,强烈推荐看英文版的
Learn how to use, configure, and set up tools for applications that use RESTful web services to prevent misuse of resources Get to know and fix the most common vulnerabilities of RESTful web services ...
Java-RESTful-Web-Service.rar