value: 指定請求的實際位址,指定的位址可以是uri template 模式(後面將會說明);
method: 指定請求的method型別, get、post、put、delete等;
produces: 指定返回的內容型別,僅當request請求頭中的(accept)型別中包含該指定型別才返回;
params: 指定request中必須包含某些引數值是,才讓該方法處理。
headers: 指定request中必須包含某些指定的header值,才能讓該方法處理請求。
@controllervalue的uri值為以下三類:public
class
private
@autowired
public
}return
}return
}public
return
new }
public
if(result.haserrors()) }}
a) 可以指定為普通的具體值;
b) 可以指定為含有某變數的一類值(uri template patterns with path variables);
c) 可以指定為含正規表示式的一類值( uri template patterns with regular expressions);
example b)
public
string findowner(@pathvariable string ownerid, model model)
example c)
public
void
handle(@pathvariable string version, @pathvariable string extension) }
cousumes的樣例:
@controllerproduces的樣例:public
void
addpet(@requestbody pet pet, model model)
@controllerparams的樣例:@responsebody
public
pet getpet(@pathvariable string petid, model model)
@controller僅處理請求中包含了名為「myparam」,值為「myvalue」的請求;public
class
relativepathuritemplatecontroller
}
headers的樣例:
@controller僅處理request的header中包含了指定「refer」請求頭和對應值為「public
class
relativepathuritemplatecontroller
}
」的請求; restful開發教程
restful架構,就是目前最流行的一種網際網路軟體架構。它結構清晰 符合標準 易於理解 擴充套件方便,所以正得到越來越多 的採用。restful 即representational state transfer的縮寫 其實是乙個開發理念,是對http的很好的詮釋。非rest的url http qu...
Restful風格開發
全稱 representational state transfer 強制翻譯 表述性狀態轉移 傳輸 1.restful 是一種風格 而非一種標準 2.根據此風格設計的軟體更簡潔且有層次 3.與rest 並列的方案 soap,rpc 4.以最適合使用者的任意形式將資源傳輸出去 1 使用者 可以是客戶...
Django開發部落格 RESTful
1.介紹 restful api是指符合rest風格的web介面 具體來說就是將所有被請求的實體當作資源,通過http自帶的方法 get,head,post,put,delete 來進行對應的增刪改查等操作。比如 獲取使用者列表 get user 獲取id為1的使用者資源 get user 1 建立...