HTTP方法web |
URI服務器 |
方法名app |
參數dom |
示例url |
備註對象 |
GET接口 |
/resource資源 |
indexit |
|
@RequestMapping()io @ResponseBody Public Result index(Domain condition) |
顯示全部資源 |
GET |
/resource/1 |
show |
Id=1 |
@RequestMapping(path=」{id}」) @ResponseBody public Result show(@PathVariable Long id)
|
顯示單個資源 |
GET |
/resource/1/edit |
edit |
Id=1 |
@RequestMapping(path=」{id}/edit」) @ResponseBody public Domain edit(@PathVariable Long id);
|
編輯單個資源 |
GET |
/resource/new |
editNew |
|
@RequestMapping(path=」new」); public String editNew();
|
新建 |
POST |
/resource |
create |
|
@RequestMapping(method=RequestMethod.POST); @ResponseBody public Result create(Domain domain);
|
建立單個資源 |
PUT |
/resource/1 |
update |
Id=1 |
@RequestMapping(path=」{id}」,method=RequestMethod.UPDATE); @ResponseBody public Result update(@PathVariable Long id);
|
更新單個資源 |
DELETE |
/resource/1 |
destroy |
Id=1 |
@RequestMapping(path=」{id}」,method=RequestMethod.DELETE); @ResponseBody public Result destroy(@PathVariable Long id);
|
刪除單個資源 |
POST |
/resource/batch/create |
batchCreate |
|
@RequestMapping(path=」batch/create」,method=RequestMethod.POST); @ResponseBody public Result batchCreate(List<Domain> domains); |
建立多個資源 |
POST |
/resource/batch/update |
batchUpdate |
|
@RequestMapping(path=」batch/update」,method=RequestMethod.POST); public Result @ResponseBody batchUpdate(List<Domain> domains);
|
更新多個資源 |
POST |
/resource/batch/destroy |
batchDestroy |
|
@RequestMapping(path=」batch/destroy」,method=RequestMethod.POST); @ResponseBody public Result batchDestroy(List<Domain> domains);
|
刪除多個資源 |
POST/GET |
/resource/action |
action |
|
@RequestMapping(path=」action」); @ResponseBody public Result action(參數);
|
對資源的其餘操做 |
說明:
1.resource表明對服務器請求的資源,好比進件,客戶資料,發標信息等等
2.action表明除crud外的操做,命名儘可能見文知意
3.標藍色的對於SPA來講可能不須要,若是是傳統的web頁面則須要
4.參數只列出了url中的,表單中的未在上表格中體現
5.Domain泛指各類實體,寫具體接口要以具體實體類替換
6.Result有兩種含義,一種是泛指返回的結果類型,能夠是各類實體或實體集合等等,另一種是指結果的封裝,即Result中封裝Message對象與實體對象,Message對象提供處理結果與消息,實體對象做爲展現數據,這裏推薦第二種方式
有好的意見,請你們提出來,謝謝。