[英]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.