zoukankan      html  css  js  c++  java
  • 前后端接口传输参数方式 post(json, formdata) get

    方式一:前端以json串的方式传输, post请求

    getCopyCourseInfo(
            this.form
          ).then(response => {
            this.courseList = response.data
            this.isresult = true
          })

      接口post的请求方式:

    export function getCopyCourseInfo(data) {
      console.log('data = ', data)
      return request({
        url: '/course/getCopyCourseInfo',
        method: 'post',
        data
      })
    }
    

      服务端接口接收方式

     @PostMapping(value = "/getCopyCourseInfo")
        public ResponseMessage getCopyCourseInfo(@RequestBody JSONObject request){
        String courseId = request.getString("courseId");
    }
    

      

    方式二:  以参数的形式传递 post请求 formdata

    getIdByActivity({
            discountActvId: this.discountActvId, env: this.form.env, cookie: this.form.cookie
          }).then(response => {
            const res = response.data
            this.renewId = res
          })
    
    export function getIdByActivity(data) {
      return request({
        url: '/course/getIdByActivity',
        method: 'post',
        params: data
      })
    }
    

      服务端请求方式 post请求  formdata的形式

    @RequestMapping(value = "/getIdByActivity")
        public Object getIdByActivity( @RequestParam String env,@RequestParam Integer discountActvId, @RequestParam String cookie)
    

     方式三: get 方法

    getStudentMhdHeader({ showBuyCourses: this.showBuyCourses, showAttendance: this.showAttendance }).then(response => {
            this.tableData = response.data
            console.log('this.tableData=', this.tableData)
            this.getList()
          })
    

      

    export function getStudentMhdHeader(query) {
      return request({
        url: '/studentMhd/getHeader',
        method: 'get',
        params: query
      })
    }
    

      

    @GetMapping("/getHeader")
        public ResponseMessage getHeader(@RequestParam(required = false) Boolean showBuyCourses,
                                         @RequestParam(required = false) Boolean showAttendance)
    

      

     

      

  • 相关阅读:
    centos5&6的启动过程
    linux之目录知识
    js动画
    js操作高级
    js操作
    JS基础
    跨域问题
    MySQL存储引擎
    MySQL索引管理
    MySQL操作命令
  • 原文地址:https://www.cnblogs.com/leavescy/p/14558871.html
Copyright © 2011-2022 走看看