I want to submit an input of type "date" to a spring mvc Controller. Unfortunately, I keep getting numerous errors. I'm new to spring mvc and especially to form submitting, not very clear to me why I need to have "commandName" in form.
My code so far:
backoffice.jsp:
<form:form method="POST" action="/getAllOnDate" commandName="date">
<table>
<td><form:label path="date">Date</form:label></td>
<td><form:input type="date" path="date"/></td>
<input type="submit" value="View all on date"/>
</table>
</form:form>
Controller:
@RequestMapping(value = "/backoffice", method = RequestMethod.GET)
public String backofficeHome(Model model) {
model.addAttribute("date", new Date());
return "backoffice";
}
@RequestMapping(value = "/getAllOnDate", method = RequestMethod.POST)
public String getAllReservationsForRestaurantOnDate(@ModelAttribute("date") Date date, Model model) {
LOG.info(date.toString());
return "anotherPage";
}