Добрый день.
Имеется такой эндпоинт
@PostMapping(value = "/products/add", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
public String addProduct(@RequestBody ProductDTO productDTO) {
service.addProduct(productDTO);
return "redirect:/products";
}
И такая jps
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8"/>
<title>Add product</title>
</head>
<body>
<div>
<form action="#" th:action="@{/products/add}" th:object="${productDTO}" method="post">
<input type="hidden" name="id">
<input type="text" name="productName" placeholder="Press name" />
<input type="text" name="productDescription" placeholder="Press description">
<input type="number" name="productPrice" placeholder="Press price">
<input type="number" name="stockBalance" placeholder="Press stockbalance">
<button type="submit">Add product</button>
</form>
</div>
</body>
</html>
Когда отправляю с этой формы POST, то ловлю ответ 415.
Resolved exception caused by Handler execution: org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported
Подскажите, в чем может быть проблема?