增加Maven坐标:
org.apache.poi
poi
3.17
org.apache.poi
poi-ooxml
3.17
修改VUE请求头:
postUpload(url, data) {
//data.append('ticket', user(null))
return new Promise((resolve, reject) => {
axiosUpload
.post(url, data, { headers: { 'Content-Type': 'multipart/form-data' } })
.then(
res => {
if (res.res === 'failed') {
if (res.code === 'encrypt') {
// 转到无权限页
// console.log('触发无权限')
_this.$router.push('/encrypt')
} else if (res.code === 'no-encrypt') {
// console.log('触发重新登录')
// 转到登录页(redirect)
MessageBox.alert('登录信息已失效,请重新登录!', '提示', {
confirmButtonText: '确定',
// cancelButtonText: '',
type: 'warning'
})
.then(() => {
_this.$router.push('/login')
})
.catch(() => {
_this.$router.push('/login')
})
} else {
resolve(res)
}
} else {
resolve(res)
}
},
err => {
reject(err)
}
)
})
},
export default {
post(url, data) {
console.log('post request url', url)
return service({
method: 'post',
url,
params: data
})
},
或者用
upLoadFile(url, data) {
console.log('upLoad request url', rul)
return axiosx.post(url, data, {
headers: { 'Content-Type': 'multipart/form-data' }
})
}
JAVA:
@ApiOperation(value = "导入国家字典信息", notes = "导入国家字典信息")
@ApiImplicitParam(name = "ticket", value = "用户标识", required = true, dataType = "String", paramType = "form")
@PostMapping(value = "/importCountyExcelFile" )
public void importCountyExcelFile(HttpServletRequest request, HttpServletResponse response,
@ApiParam(value="文件",required=true) @RequestPart MultipartFile file) {
ServletCom com = new ServletCom(request, response);
List
VUE:
{{ $t('国家管理') }}
{{ $t('新增') }}