Vue, spring boot, jpa environment. An error occurs on the client when uploading a file

14 Views Asked by At
@PostMapping(value = "/admin/item/new", consumes = {MediaType.MULTIPART_FORM_DATA_VALUE})
public ItemNewResponse itemNew(@RequestParam(value = "itemImgFile") List<MultipartFile> files ) {

...

enter image description here

As a result of running Postman, there is no problem with the backend.

enter image description here

Front-End ...

 const formData = new FormData();  
  for(let i = 0; i < this.upload.length; i++) {
    formData.append('itemImgFile', this.upload[i])
  }

  axios.post("admin/item/new", formData, {
    headers: {
      'Content-Type': 'multipart/form-data',
      'Access-Control-Allow-Origin': '*',
    },
    withCredentials: true
  }).then(({data}) => {

    state.errorMessage = data.errorMessage;

    if (state.errorMessage != null) {
      alert(state.errorMessage);
    }
    ...

I don't know what's wrong with vue.

0

There are 0 best solutions below