---
title: "restful是什么"
author: "noble510520"
date: "2016-06-07T21:50:00Z"
tags: ["Restful"]
categories: ["企业架构"]
slug: "restful"
draft: false
lastmod: "2016-06-15T20:07:03Z"
id: 2304950
url: "https://zswlib.iteye.com/blog/2304950"
---

# resful是什么

rest是一种**开发的风格**，他不是框架，也没有类库，是一种**约定**

# 有什么不同

## 非restful的开发方式

当没有接触restful的时候，URL通常是动词，比如127.0.0.1:8080/unrestful/getFile

## restful的开发方式

restful的URL是名词，比如127.0.0.1:8080/restful/file

**通过请求消息的method来调用具体的业务**

### 约定的method

- get，获取数据
- post，新增数据
- put，更新数据
- delete，删除数据

# 约定大于配置

当约定好get、post、put、delete这几种method对应处理什么样的业务之后，后台就要根据请求的method去调用相应的方法

**而不是从配置文件中拿到，request method对应的action method**

# 好处

restful开发，可以使接口的URL更简洁，而且数量更少

查看原文：[http://www.wewill.top/2016/06/07/restful%E6%98%AF%E4%BB%80%E4%B9%88/](http://139.129.55.235/2016/06/07/restful%e6%98%af%e4%bb%80%e4%b9%88/)