// vue 中的调用方法
handleModelUpload() {
alert('下载zip模板')
axios({
method: 'GET',
url: '/business/api/download',
// params: {
// // eslint-disable-next-line no-undef
// reportRuleId: row.reportRuleId
// },
responseType: 'blob'
}).then(response => {
const blob = new Blob([response.data], { type: 'application/zip' })
const url = window.URL.createObjectURL(blob)
window.location.href = url
}).catch(error => this.$message.error(error) )
},
如上图中的前端method,/bussiness 带代理我后台的 ip 实际getMapping的路径是/api/download。下面是后台的java api
package com.picchealth.mono.api;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.Rest