I have the POST
request API call to accept the JSON
body request parameters and multipart file from the client side. 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"}"]
I think I have a problem with my CategoryModel
but I do not know why:
This is my 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