spring - "HTTP Status 405 - Request method 'POST' not supported" on form submit -
Trying to make a very simple form in Spring / Hibernate, it should add the entry to the database. This is an example that has worked for me, so it is weird that I am getting this error. But this is what it is that is it.
The page is with this form:
prefix @ taglib uri = "http://java.sun.com/jsp/Jstl/ core" = "C"%> & Lt;% @ taglib uri = "http://www.springframework.org/tags/form" prefix = "form"% & gt; & Lt; Html & gt; & Lt; Head & gt; & Lt; Title & gt; Add Ownership Game & lt; / Title & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; H1 & gt; Add ownership game & lt; / H1> & Lt; Br / & gt; & Lt; Br / & gt; & Lt; C: url var = "saveGameeUrl" value = "/ games / save.html" / & gt; & Lt; Form: Form Model Attribute = "Game" method = "Post" action = "$ {saveGameUrl}" & gt; & Lt; Form: label path = "title" & gt; Game title: & lt; / Form: label & gt; & Lt; Form: input path = "title" / & gt; & Lt; Br / & gt; & Lt; Input type = "submit" value = "add game" /> & Lt; / Form: Form & gt; & Lt; / Body & gt; & Lt; / Html & gt; And here's the relevant control method:
@RequestMapping (value = "/ save", method = RequestMethod.POST) Save public models and views. @ModelAttribute ("game") game game, binding result result) {gameService.addOwnedGame (game); Return a new model and view ("redirect: /games/known.html"); } If you need to see something else, let me know.
It looks like you're posting on the HTML page instead of the / save page (which is stable Which should be the route for a controller, is it a typo? C: url has been named saveGameeUrl with two S, whereas in action only has an E on the game. & lt; C: url var = "save_ameeUrl" value = "/games/save.html" /> & Lt; Form: Form Model Attribute = "Game" method = "Post" action = "$ {saveGameUrl}" & gt;
Comments
Post a Comment