![]() |
![]() |
|||||||
Status: Final | ||||||||
Stage | Start | Finish | ||||||
Final Release | Download page | 10 Oct, 2008 | ||||||
Final Approval Ballot | View results | 09 Sep, 2008 | 22 Sep, 2008 | |||||
Proposed Final Draft | Download page | 15 Aug, 2008 | ||||||
Public Review Ballot | View results | 27 May, 2008 | 02 Jun, 2008 | |||||
Public Review | Download page | 02 May, 2008 | 02 Jun, 2008 | |||||
Early Draft Review | Download page | 24 Oct, 2007 | 23 Nov, 2007 | |||||
Expert Group Formation | 27 Feb, 2007 | 15 Aug, 2007 | ||||||
JSR Review Ballot | View results | 13 Feb, 2007 | 26 Feb, 2007 | |||||
JCP version in use: 2.6 Java Specification Participation Agreement version in use: 2.0 Please direct comments on this JSR to: jsr-311-comments@jcp.org |
與其它規(guī)范發(fā)布一樣,伴隨此次發(fā)布,Sun同步發(fā)布該規(guī)范的參考實(shí)現(xiàn)項(xiàng)目jersey。最新版本為1.0。 為了讓大家能快速體驗(yàn)Rest帶給我們?nèi)碌募軜?gòu)風(fēng)格,可以直接從本地下載程序。bookstore-1.0.war 源代碼 bookmark-1.0-project.zip.
下面展示了一個(gè)代碼片斷,讓大家直觀感受一下。
1 @Path("/bank")
2 public class Bank {
3
4 @POST
5 @Path("/account/{name}")
6 public Account createAccount(@PathParam("name") String name,
7 @QueryParam("balance")BigDecimal balance) {
8 //
9 return new Account(name, balance);
10 }
11
12 @GET
13 @Path("/account/{name}")
14 public Account getAccount(@PathParam("name") String name) {
15 //
16 return Account.getByName(name);
17 }
18
19 }
20
2 public class Bank {
3
4 @POST
5 @Path("/account/{name}")
6 public Account createAccount(@PathParam("name") String name,
7 @QueryParam("balance")BigDecimal balance) {
8 //

9 return new Account(name, balance);
10 }
11
12 @GET
13 @Path("/account/{name}")
14 public Account getAccount(@PathParam("name") String name) {
15 //

16 return Account.getByName(name);
17 }
18
19 }
20
上面的代碼,就會(huì)發(fā)布兩個(gè)資源服務(wù):
POST /bank/account/newAccount
GET /bank/account/newAccount
大家看到,用Rest發(fā)布資源服務(wù)非常方便。當(dāng)然上面例子只是一個(gè)非常簡(jiǎn)單的示例,用于展示Rest的應(yīng)用,也希望大家提出好的建議和意見。
Good Luck!
Yours Matthew!