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

因为有规定必须用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

你可能感兴趣的:(vue,java)