vue前台向springboot后台传json参数

一、前台

1、data.js

import axios from '@/libs/api.request'
//ajax请求  根据id查询企业
export const getTest = info => {
  return axios.request({
    url: '/analyze/test',
    data:info,
    method: 'post'
  })
}

2、statistics.vue

handleSubmit(data) {
      // 行业分类
      var industryType=document.evaluate("//*[@id='app']/div/div[2]/div[2]/div/div[2]/div[1]/div[1]/form/div[1]/div/div/div/div[1]/div/span",document).iterateNext().textContent;
      //大类
      var bigType=document.evaluate("//*[@id='app']/div/div[2]/div[2]/div/div[2]/div[1]/div[1]/form/div[2]/div/div/div/div[1]/div/span",document).iterateNext().textContent;
      //门类
      var smallType=document.evaluate("//*[@id='app']/div/div[2]/div[2]/div/div[2]/div[1]/div[1]/form/div[3]/div/div/div/div[1]/div/span",document).iterateNext().textContent;
      console.log(industryType)
      console.log(bigType)
      console.log(smallType)
      getTest({"industryType":industryType,"bigType":bigType,"smallType":smallType}).then(data => {
				console.log("success");
        })
	  }

二、后台

1、controller类

@RestController
@RequestMapping("/analyze")
public class AnalyzeController {
	@PostMapping("test")
    public void Test(@RequestBody Test test){
        System.out.println(test.getBigType());
        System.out.println(test.getIndustryType());
        System.out.println(test.getSmallType());
    }
}

2、实体类

public class Test {
    private String industryType;
    private String bigType;
    private String smallType;

    public String getIndustryType() {
        return industryType;
    }

    public void setIndustryType(String industryType) {
        this.industryType = industryType;
    }

    public String getBigType() {
        return bigType;
    }

    public void setBigType(String bigType) {
        this.bigType = bigType;
    }

    public String getSmallType() {
        return smallType;
    }

    public void setSmallType(String smallType) {
        this.smallType = smallType;
    }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Antgeek

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值