試圖在Spring/Hibernate中做一個非常簡單的表單。它應該添加一個條目到數據庫中。這是基於一個爲我工作的例子,所以奇怪的是我會得到這個錯誤。但是它就是這樣啊。表單提交時「HTTP狀態405 - 請求方法'不支持POST'
下面是與窗體頁:
<%@ 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>
而這裏的相關負責人方法:
@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");
}
如果你需要看別的,讓我知道。
你看過服務器日誌嗎? – PhD 2012-07-11 23:30:59
服務器日誌中沒有任何內容。 – lashiel 2012-07-11 23:32:22