文档详情

RESTful web service.ppt

发布:2016-03-24约5.2千字共19页下载文档
文本预览下载声明
客户端代码 import java.io.IOException; import mons.httpclient.HttpClient; import mons.httpclient.HttpException; import mons.httpclient.HttpStatus; import mons.httpclient.methods.GetMethod; public class RESTWithHTTPClient { public static void main(String[] args) { HttpClient client = new HttpClient(); GetMethod method = new GetMethod(/statuses/public_timeline.xml); try { int statusCode = client.executeMethod(method); if (statusCode == HttpStatus.SC_OK) { System.out.println(new String(method.getResponseBody())); } } catch (HttpException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { method.releaseConnection(); } } } 服务器代码 import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import com.sun.jersey.api.container.httpserver.HttpServerFactory; import .httpserver.HttpServer; import java.io.IOException; //指定URI @Path(/helloworld) public class HelloWorld { //处理HTTP的GET请求 @GET // 处理请求反馈的内容格式为text/plain @Produces(text/plain) public String getClichedMessage() { return Hello World!\nShaoBaoguo!!!; } public static void main(String[] args) throws IOException { //创建RESTful WebService服务 HttpServer server = HttpServerFactory.create(5:9999/); server.start();//启动服务 System.out.println(RESTful WebService服务已经启动); System.out.println(服务访问地址: 5:9999/helloworld); } } 求职应注意的礼仪 求职时最礼貌的修饰是淡妆 面试时最关键的神情是郑重 无论站还是坐,不能摇动和抖动 对话时目光不能游弋不定 要控制小动作 不要为掩饰紧张情绪而散淡 最优雅的礼仪修养是体现自然 以一种修养面对两种结果 必须首先学会面对的一种结果----被拒绝 仍然感谢这次机会,因为被拒绝是面试后的两种结果之一。 被拒绝是招聘单位对我们综合考虑的结果,因为我们最关心的是自己什么地方与用人要求不一致,而不仅仅是面试中的表现。 不要欺骗自己,说“我本来就不想去”等等。 认真考虑是否有必要再做努力。 必须学会欣然面对的一种结果----被接纳 以具体的形式感谢招聘单位的接纳,如邮件、短信 考虑怎样使自己的知识能力更适应工作需要 把走进工作岗位当作职业生涯的重要的第一步,认真思考如何为以后的发展开好头。 Thank you R
显示全部
相似文档