2013-05-05 6 views
2

GET 요청을받는 다른 Spring 컨트롤러로 요청을 전달하려하지만 POST가 지원되지 않는다고 알려줍니다. 다음은 POST 함수를 사용하는 첫 번째 컨트롤러 메소드의 관련 부분입니다. 로그인 함수로 사용하고 있기 때문입니다.Spring 3 - 전달에서 GET 요청을 수행하는 방법

@RequestMapping(value = "/login", method = RequestMethod.POST) 
public String login(@ModelAttribute("administrator") Administrator administrator, 
    Model model) { 
    // code that's not germane to this problem 
    return "forward:waitingBulletins"; 
} 

다음은 앞으로 전달할 방법입니다.

@RequestMapping(value = "/waitingBulletins", method = RequestMethod.GET) 
public String getWaitingBulletins(Model model) { 
     // the actual code follows 
    } 

다음은 브라우저의 오류 메시지입니다. 당신이 POST 요청을 전달하고 그것을 위해 핸들러를 누락 있도록

HTTP Status 405 - Request method 'POST' not supported 

-------------------------------------------------------------------------------- 

type Status report 

message Request method 'POST' not supported 

description The specified HTTP method is not allowed for the requested resource (Request method 'POST' not supported). 

답변

4

forward은 원래 요청을 그대로 유지합니다.

실제로 보았을 때 앞으로 구현하는 대신 리디렉션을 사용하는 POST-redirect-GET 패턴입니다. 작동하도록

@RequestMapping(value = "/login", method = RequestMethod.POST) 
public String login(@ModelAttribute("administrator") Administrator administrator, 
    Model model) { 
    // code that's not germane to this problem 
    return "redirect:waitingBulletins"; 
} 

:

는 만에 POST 핸들러를 변경해야합니다.

+0

감사합니다. 이것은 나를 위해 일했다. –

관련 문제