代码改变世界

随笔档案-2011年10月13日

RestEasy 用户指南---第11章 @FormParam

2011-10-13 16:17 by Shawn.Cheng, 885 阅读, 收藏,
摘要: 当你以application/x-www-form-urlencoded格式去编码,并将这些内容放在请求的实体(request body)中,例如html的form表单。你可以将自主定制的参数传入到方法的参数中。<form method="POST" action="/resources/service"> First name: <input type="text" name="firstname"> <br> Last name: <input type="t 阅读全文

ReatEasy+用户指南----第9章@MatrixParam

2011-10-13 16:14 by Shawn.Cheng, 343 阅读, 收藏,
摘要: Matrix param的做法是你可以在uri 的path segmen中嵌入任意个数个name 和value的键值对。下边是一个例子GET http://host.com/library/book;name=EJB 3.0;author=Bill BurkeMatrixparameters的基本思想是 这些参数代表了一个资源。@MatrixParam的声明允许你在uri中传入参数,以供方法调用使用。@GET public String getBook(@MatrixParam("name") String name, @MatrixParam("author&q 阅读全文

RestEasy 用户指南----第7章 @HeaderParam

2011-10-13 16:12 by Shawn.Cheng, 364 阅读, 收藏,
摘要: @HeaderParam的声明允许你将request http header映射到你所调用的方法中GET/books?num=5 @GET public String getBooks(@HeaderParam("From") String from) { ... }就像PathParam一样,你的参数类型可以是一个String primitive或者是一个有一个String构造方法的类再或者一个静态的valueOf()方法。例如MediaType有个valueOf()的静态方法,你就可以 @PUT public void put(@HeaderParam("Co 阅读全文

RestEasy用户指南---第6章.@QueryParam

2011-10-13 16:10 by Shawn.Cheng, 357 阅读, 收藏,
摘要: @QueryParam的声明允许将一个uri的查询字符串参数,或者url编码形式的参数映射到你的方法调用中。GET/books?num=5View Code @GET public String getBooks(@QueryParam("num") int num) { ... } (意思大概是说你通过查询字符串传递的参数可以通过@QueryParam来传递获取)目前,resteasy实在Servlet的基础之上运行的,它并不区分URI查询字符串和Uri编码形式的参数。就像PathParam一样,你的参数类型可以是一个String primitive或者是一个有一个Str 阅读全文

RestEasy+用户指南----第5章.@PathParam

2011-10-13 16:08 by Shawn.Cheng, 352 阅读, 收藏,
摘要: @PathParam 的声明允许你在URI路径中去映射你的方法将使用的参数。@Path("/library")public class Library { @GET @Path("/book/{isbn}") public String getBook(@PathParam("isbn") String id) { // search my database and get a string representation and return it }}(很简单,当你发出get请求 /book/152-963参数152-963就在is 阅读全文

RestEasy 用户指南----第4章.使用@Path @GET @POST 等

2011-10-13 15:59 by Shawn.Cheng, 480 阅读, 收藏,
摘要: View Code @Path("/library")public class Library { @GET @Path("/books") public String getBooks() {...} @GET @Path("/book/{isbn}") public String getBook(@PathParam("isbn") String id) { // search my database and get a string representation and return it } @PUT @P 阅读全文

RestEasy+用户指南+翻译索引

2011-10-13 15:52 by Shawn.Cheng, 359 阅读, 收藏,
摘要: 最近的项目开发要用到RestEasy,在网上没有找到中文版帮助文档。看了看原版英文的,不是很复杂,就翻译一下,水平有限,如有错误,敬请指出。原文地址http://docs.jboss.org/resteasy/docs/2.2.1.GA/userguide/html/index.html我先翻译那些项目中用到的地方。下边是RestEasy 用户指南 翻译的索引RestEasy 用户指南----第4章.使用@Path @GET @POST 等RestEasy 用户指南----第5章.@PathParamRestEasy用户指南---第 6章. @QueryParamRestEasy 用户指南-- 阅读全文