2012-07-11 3 views
0

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"); 
} 

알려주세요.

+0

서버 로그를 보았습니까? – PhD

+0

서버 로그에 아무것도 없습니다. – lashiel

답변

2

컨트롤러로 라우팅 할/save 페이지 대신 HTML 페이지 (정적이어야 함)에 게시하는 것처럼 보입니다. 또한, 오타입니까? c : url의 이름은 saveGameeUrl이고 두 개의 Es가있는 반면 게임에는 하나의 e 만 있습니다.

<c:url var="saveGameeUrl" value="/games/save.html" /> 
<form:form modelAttribute="game" method="POST" action="${saveGameUrl}"> 
+0

소년 오, 내 뺨이 붉지 않아. 나는 그것을 어느 시점에서 고쳤다 고 생각했다. 그것은 그것을 고쳤다! – lashiel

+0

문제는 없습니다. 누군가가 코드 검토를 통해 머리를 터뜨린 것은 처음이 아닐 것입니다 :). – Wulfram

관련 문제