Day75 :) RestAPI
4288 ワード
API
Rest
コンポーネント
GET /students/hong
Response
{
"name": "홍길동",
"age": 30,
"gender": "male"
}
特長
Uniform
Stateless
Cacheable
Self-descriptiveness
Client-Server
階層構造
REST API
RESTful API
REST API設計規則
名詞と小文字を使う
http://example/getSample(X)
http://example/Sample(X)
http://example/sample(O)
階層関係をスラッシュ(/)で表す
http://example/students/hong
URI末尾にスラッシュは含まれません(/)
下の列()の代わりにハイフン(-)を使用
レスポンスステータスコードの使用
https://ko.wikipedia.org/wiki/HTTP_%EC%83%81%ED%83%9C_%EC%BD%94%EB%93%9C
URIは拡張子を含まない
http://example/students/hong.html(X)
http://example/students/hong(O)
リファレンスSpring Rest APIの実装
追加ライブラリ(ジャクソン)
依存性
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.13.1</version>
</dependency>
RestControlの作成
@Controllerの使用
@Controller
@ResponseBody
public class Sample1{
로직
}
@RequestBody
@ResponseBody
@RestControlの使用
@RestController
public class Sample2{
로직
}
Reference
この問題について(Day75 :) RestAPI), 我々は、より多くの情報をここで見つけました https://velog.io/@yoonee1126/Day75テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol