请求,响应

请求方法

  1. get:被用来检索数据,retreive data from a server at the specified resource.
    get请求仅仅用来请求数据,并不是修改任何resources。是一种安全有效的方式。
  2. post:be used to send data to the API server to create or update a resource。被用来发送数据给服务端来修改或者创建数据。数据被用来存储在http请求的request body里。
  3. put:simlar to post.
  4. patch:
  5. delete:

Request

  1. Javax.servlet.http.HttpServletRequest
    GetHeader()
    Return String 对request header 的详细说明,specified
    If 请求中不包含 not include a header of specified name ,return null
    If 对于 same name ,there are multiple headers,这个方法return the first head in the request,返回请求中的第一个head,the header name is case insensitive头名是不区分大小写的,你可以使用this method whis any request header
    Public java.lang.String getheader(java.lang.String name)

Response

JSON

  1. 模拟数据格式:单条数据
{"a":"2.12","b":"2.12"}
  1. 数组格式:
{"a":"",
[
{"b":"b1","c":"2.12"},
{"b":"b1","c":"2.12"}
]
}
  1. 字符串格式:
{
"engineeringId":"01",
"versionId":"01",
"documentId":"01",
"calculationFloor":"1楼",
"elevationList":["a","b"]
}
  1. String[] ids和List ids在Get请求和Post请求的不同处
    在postman中的post请求方式同下:
    [“1”,“2”,“3”]
    get请求:param:ids 1,3 ————>最后路径中/api/delete/ids=1,3
    get请求下:String[] 到controller层会转化为{“1”,“3”}
    List<> 下就是size =2 的形式

  2. List 转JSONArray 再转String

JSONArray.parseArray(JSON.toJSONString(ids)).toString
和JSON.toJSONString(ids)是等价的
发布了4 篇原创文章 · 获赞 0 · 访问量 50

猜你喜欢

转载自blog.csdn.net/fireworksunshine/article/details/105387920
今日推荐