I get an Request method 'POST' not supported error
every time I press the button
EventController.java fragment
@PostMapping(value = "/ledger/{id}/get-place")
public String modifyLedger(@PathVariable(value = "id") long id, @RequestParam Long place, Model model) {
Event event = eventRepository.findById(id).orElseThrow();
event.setPlace(place - 1);
eventRepository.save(event);
return "ledgerInfo";
}
That function suppose to substract 1 from Long place
variable every time when i press the button but every time i got an HttpRequestMethodNotSupportedException
error
LedgerInfo.html
<div class = "container mt-5">
<h1>Ledger Info</h1>
<div th:each="elem:${event}" class="alert alert-info mt-2">
<h2 th:text="${elem.title}"/>
Line count:<p th:text="${elem.line}"/>
Place remain:<p th:text="${elem.place}"/>
Place status:<p th:text="${elem.status}"/>
<form method="post">
<button type="submit" class="btn btn-success">Get Place</button>
</form>
</div>
</div>
You did not specified the action for your form. Use th:action="@{/your Url}" in the form tag.