1.get传输多个参数,后端使用实体类接收

前端:
let query ={
    id:1,
    name:'小红'
}
export function workMakeupList(query) {
  return request({
    url: '/work/makeup/list',
    method: 'get',
    params: query
  })
}

后端控制层:
@GetMapping("/list")
public List list(Student s){
    List s = null;
    return s;
}

//实体
public class Student{
    private Long id,
    private String name
}

2.get传输多个参数,后端分别接收

前端
let query = {
  id: 1,
  name:'小红'
}
export function workMakeupList(query) {
  return request({
    url: '/work/makeup/list',
    method: 'get',
    params: query
  })
}
后端控制层:
@GetMapping("/list")
public List list(@RequestParam("id") Long id,@RequestParam("name") String name){
    List s = null;
    return s;
}

3.get通过url传输多个参数,后端分别接收

let id =1
let name='小红'
export function workMakeupList(id,name) {
  return request({
    url: '/work/makeup/list/'+id+'/'+name,
    method: 'get'
  })
}

后端控制层:
@GetMapping("/list/{id}/{name}")
public List list(@PathVariable("id") Long id,@PathVariable("name") String name){
    List s = null;
    return s;
}

4.post传输参数,后台使用实体类接收

前端:
let query ={
    id:1,
    name:'小红'
}//or  query= this.form(从表单直接数据)
export function workMakeupList(query) {
  return request({
    url: '/work/makeup/list',
    method: 'post',
    data: query
  })
}

后端控制层:
@GetMapping("/list")
public List list(@RequestBody Student s){
    List s = null;
    return s;
}
//实体
public class Student{
    private Long id,
    private String name
}

5.get传入,后端用数组接收(常用于批量删除)

前端
let query ={
    ids:"1,2,3,4"
}

export function workMakeupList(query) {
  return request({
    url: '/work/makeup/list',
    method: 'get',
    params: query
  })
}

后端控制层:
@GetMapping("/list")
public List list(@RequestParam("ids") Long[] ids)
{
        List s = null;
        return null;
}

 

Logo

前往低代码交流专区

更多推荐