或許你在一些國外的Blog上看到過REST這個詞,下面用一個很簡單的例子說明一下REST的定義.
以瀏覽網(wǎng)頁為例, 當你要查看某個網(wǎng)頁的時候, 你需要在瀏覽器上輸入該網(wǎng)頁的URL. 當你發(fā)出對idior.cnblogs.com這個資源的請求后, 一個該資源的表現(xiàn)形式(Representation)將返回給你, 也就是idior.cnblogs.com相應的html文件. 這時候你就進入一個狀態(tài)(State), 也就是查看我的blog首頁的狀態(tài), 當你在我的blog中點擊了某個鏈接http://idior.cnblogs.com/category/46628.html, 你又對另一個資源發(fā)出了請求, 隨后得到一個Representation, 因此你轉為(Transfer)另一個狀態(tài)(State).
Client application transfers state with each resource representation. This is REST.
REST is not a standard. You will not see the W3C putting out a REST specification. You will not see IBM or Ms selling a REST developer's toolkit. Why? Because REST is just an architectural style. You can't bottle up that style. You can only understand it, and design your Web service in that style.
While REST is not a standard, it does prescribe the use of standards:
--- HTTP
--- URL
--- XML/HTML/GIF/JPEG/etc (Resource Representations)
--- text/xml, text/html, image/gif, image/jpeg, etc (Resource Types, MIME Types)
浙公網(wǎng)安備 33010602011771號