0
0

クライアントからサーバーにリクエストデータを転送する際に主に使用する方法

Posted at
  1. Query Parameter (GET)

    localhost:8080/hello?username=ABC&age=10

    • MessageBodyなしで、URLのクエリパラメータにデータを含めて伝達する。
    • 検索、フィルター、ページングなどで多く使用する。
  2. HTML Form (POST)

    <form action="/hello" method="post">
    	<input type="text" name="username"/>
    	<input type="text" name="age"/>
    	<buttion type="submit">전송</button>
    </form>
    
    • 会員登録、商品注文のようにHTML Formを書く場合に使用する。
    • HTTPメッセージボディにGETのようなクエリパラメータ形式で伝達する。
    • POST HTML Form形式でデータを伝送する形式をapplication/x-www-form-urlencodedという。
  3. HTTP message body (POST, PUT, PATCH など )

    • HTTP message body にデータを直接入れて要請する。
    • HTTP API で主に使用し、データ形式としてはJSON XML、TEXT などがある。
    • POST、PUT、PATCHなどをすべて使用できる。

    3.1. Content-Type : text/plain、単純テキストの場合
    스크린샷 2023-09-24 17.01.06.png

    3.2. Content-Type : application/json, JSONの場合
    스크린샷 2023-09-24 17.06.48.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0