简体   繁体   English

嵌套的异常是java.lang.NumberFormatException:用于输入字符串/用于弹簧启动的Multipart文件和json数据

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

I have the POST request API call to accept the JSON body request parameters and multipart file from the client side. 我有POST请求API调用,以从客户端接受JSON主体请求参数和多部分文件。 This is my method: 这是我的方法:

@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());

    }

I have this exception: 我有这个例外:

 "category_name": "ziska111"

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

This is my Postman request: 这是我的邮递员要求: 在此处输入图片说明

I think I have a problem with my CategoryModel but I do not know why: This is my CategoryModel: 我认为我的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.

相关问题 java-线程“ main”中的异常java.lang.NumberFormatException:对于输入字符串:“”位于 - java - Exception in thread “main” java.lang.NumberFormatException: For input string: “” at 线程“ main”中的异常java.lang.NumberFormatException:对于输入字符串:Java中的“” - Exception in thread “main” java.lang.NumberFormatException: For input string: “” in Java 线程“ main”中的异常java.lang.NumberFormatException:对于输入字符串:“ 0.06” - Exception in thread “main” java.lang.NumberFormatException: For input string: “0.06” 异常-java.lang.NumberFormatException:对于输入字符串:“ 000000000” - Exception- java.lang.NumberFormatException: For input string: “ 000000000” 线程“ Thread-3”中的异常java.lang.NumberFormatException:对于输入字符串:“” - Exception in thread “Thread-3” java.lang.NumberFormatException: For input string: “” 线程“main”中的异常 java.lang.NumberFormatException:对于输入字符串:“8/3/2012” - Exception in thread "main" java.lang.NumberFormatException: For input string: "8/3/2012" 线程“ main”中的异常java.lang.NumberFormatException:对于输入字符串:“” - Exception in thread “main” java.lang.NumberFormatException: For input string: “” 线程“main”中的异常 java.lang.NumberFormatException:对于输入字符串:“0.353” - Exception in thread “main” java.lang.NumberFormatException: For input string: “0.353” 嵌套异常是 java.lang.NumberFormatException: For input string: &quot;favicon.ico&quot;] - nested exception is java.lang.NumberFormatException: For input string: "favicon.ico"] 线程“ main”中的异常java.lang.NumberFormatException:对于输入字符串:“; - Exception in thread “main” java.lang.NumberFormatException: For input string: ";
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM