Trying to do a very simple form in Spring/Hibernate. It should be adding an entry to the database. This is based off an example which worked for me, so it’s weird that I would be getting this error. But it is what it is.
Here’s the page with the form:
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<html>
<head><title>Add Owned Game</title></head>
<body>
<h1>Add Owned Game</h1>
<br />
<br />
<c:url var="saveGameeUrl" value="/games/save.html" />
<form:form modelAttribute="game" method="POST" action="${saveGameUrl}">
<form:label path="title">Game Title:</form:label>
<form:input path="title" />
<br />
<input type="submit" value="Add Game" />
</form:form>
</body>
</html>
And here’s the relevant controller method:
@RequestMapping(value = "/save", method = RequestMethod.POST)
public ModelAndView saveGame(@ModelAttribute("game") Game game,
BindingResult result) {
gameService.addOwnedGame(game);
return new ModelAndView("redirect:/games/owned.html");
}
If you need to see anything else, let me know.
It looks like your are posting to the HTML page (which should be static) instead of the /save page which would route to a controller. Also, is it a typo? The c:url is named saveGameeUrl with two Es whereas the action only has one e on Game.