vue往后台传参(不是传对象)

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/xiaogc_a/article/details/82598063

因为有规定必须用post提交
example:
vue:

withdrawCount(){
    let formData = new FormData();
    formData.append("date",this.date);
    withdrawCount(formData).then(response => {

    });
},

js:

export function withdrawCount(query) {
    return fetch({
        url: commonUrl + '/withdrawCount',
        method: 'POST',
        data: query
    });
}

后台:

@PostMapping(value = "withdrawCount")
public Object withdrawCount(@RequestParam(required = true) int date) {
    return new UpmsResult(UpmsResultConstant.SUCCESS, dashboardService.withdrawCount(date));
}

如果传对象直接使用注解@RequestBody

猜你喜欢

转载自blog.csdn.net/xiaogc_a/article/details/82598063
今日推荐