簡體   English   中英

嵌套的異常是java.lang.NumberFormatException:用於輸入字符串/用於彈簧啟動的Multipart文件和json數據

[英]nested exception is java.lang.NumberFormatException: For input string/ Multipart file and json data to spring boot

我有POST請求API調用,以從客戶端接受JSON主體請求參數和多部分文件。 這是我的方法:

@PostMapping("/saveCategory")
    @ResponseStatus(HttpStatus.OK)
    public void createCategory( @RequestParam("file") MultipartFile file,@RequestParam("cateogry") CategoryModel category) {
        String fileName = fileStorageService.storeFile(file);

        String fileDownloadUri = ServletUriComponentsBuilder.fromCurrentContextPath().path("/downloadFile/")
                .path(fileName).toUriString();
        //category.setImage_path(fileName);

        //this.categoryRepository.save(category);

        // return new UploadFileResponse(fileName, fileDownloadUri,
        // file.getContentType(), file.getSize());

    }

我有這個例外:

 "category_name": "ziska111"

    }'; nested exception is java.lang.NumberFormatException: For input string: "{"category_name":"ziska111"}"]

這是我的郵遞員要求: 在此處輸入圖片說明

我認為我的CategoryModel有問題,但我不知道為什么:這是我的CategoryModel:

   @Entity
   @Table(name = "Category")
   @JsonIgnoreProperties({ "hibernateLazyInitializer", "handler" })
public class CategoryModel {
    @Id
    @Column(name = "id")
//@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;

private String category_name;
private String category_description;
private String image_path;

@JsonIgnore
@OneToMany( mappedBy = "category")
private Set<ProductModel> category;
+Geterrs and Setters

您嘗試將字符串轉換為整數,但是輸入字符串包含字母字符,並且無法轉換為整數

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM