Reputation: 351
How to have post mapping in controller, when content type is application/x-www-form-urlencoded;charset=utf-8 and request body has text or application/json. I have read that @requestbody does not work with urlencoded. How to reslove this issue.
Upvotes: 0
Views: 1545
Reputation: 98
@CrossOrigin
@ResponseBody
@PostMapping
public Book addBook(@RequestBody Book newBook){
Book book = new Book(newBook.getTitle());
bookRepository.save(book);
return book;
}
An example, it works
Upvotes: 0