method 四种常见请求方式
1. get (查)
传参数的话,支持 number 和 String,一般发 查询 请求
请求参数 在请求地址后面,参数可见,不能传递需要保密的信息(如密码)
参数大小受限,只能传4kb大小以内的数据。
- 浏览器地址栏,发出的是get请求
- 超链接发出的的get请求
- form表单默认发出的是get请求
2. post (增)
请求参数在请求体里面,一般发add(新增) 请求
参数不可见,可传敏感信息(如密码)
参数大小无限制,可用于上传文件
- form表单 设置了 method = “post” 时,发出的是post请求
export function queryByStoveNo(singleNo,samplingNo) {
return request({
url: '/wuli/quality/physicalPerformance/physicalSamplingNo',
method: 'get',
params: { singleNo:singleNo,samplingNo:samplingNo },
showLoading: true,
closeLoading: true
})
}
params 是请求参数
- 若后端未使用框架,接收用户输入的参数之前,先设置字符集
request.setCharacterEncoding("UTF-8");
//页面传过来的内容,一般未字符串形式
String userName = request.getParameter("username");
String passWord = request.getParameter("password");
3. put (改)
发送 修改 请求时,一般用 put
4. delete (删)
发出 删除 请求时,用 delete