[英]java - Exception in thread “main” java.lang.NumberFormatException: For input string: “” at
[英]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.