zoukankan      html  css  js  c++  java
  • http的GET方法参数中不能传列表,接收端的key会变

    如下

      async initTable() {
          await getHostAttributesForUser({'username': this.username}).then(response => {
            this.listQuery.user_preferences = response.data.preferences  # 这里是一个列表this.preference_index_list = response.data.preference_index_list
            this.colConfigs = response.data.colConfigs
            getHost(this.listQuery).then(response => {
              this.tableData = response.data.items
              this.total = response.data.total
            })
          })
        },

    实际转换发送的请求为:

    http://localhost:9528/dev-api/cmdb/host/get?node_key=saas&page=1&limit=10&user_preferences[]=公网IP&user_preferences[]=VPC私有IP&user_preferences[]=vCPU 核数&user_preferences[]=内存&user_preferences[]=实例计费方式&user_preferences[]=系统类型

    服务端接收到的request.GET内容为

    <QueryDict: {'node_key': ['saas'], 'page': ['1'], 'limit': ['10'], 'user_preferences[]': ['公网IP', 'VPC私有IP', 'vCPU 核数', '内存', '实例计费方式', '系统类型']}>

    解决方法

      async initTable() {
          await getHostAttributesForUser({'username': this.username}).then(response => {
            this.listQuery.user_preferences = _.join(response.data.preferences, ',')  #将列表转换成字符串
            this.preference_index_list = response.data.preference_index_list
            this.colConfigs = response.data.colConfigs
            getHost(this.listQuery).then(response => {
              this.tableData = response.data.items
              this.total = response.data.total
            })
          })
        },
  • 相关阅读:
    跨域问题(使用jsonp解决)
    通用Mapper使用(Maven+SSM)
    hosts文件修改(域名和IP地址对应修改)
    ExportExcel(用poi导出Excel文件:用List<Map<String,Object>>)
    activiti已结束子流程退回
    一个数据库死锁的案例
    mysql函数使用的例子
    mybatis拦截器
    Objects工具类
    Spring Boot 中读取配置属性
  • 原文地址:https://www.cnblogs.com/robinunix/p/11356594.html
Copyright © 2011-2022 走看看