Stack Overflow/스프링
[스프링] URL 호출했는데 HTTP Status 405 에러가 발생되는 경우 수정 및 해결방법
Lich King
2022. 2. 24. 09:40
HTTP Status 405 – Method Not Allowed Type Status Report Message Request method 'GET' not supported Description The method received in the request-line is known by the origin server but not supported by the target resource. |
URL을 입력하여 웹서비스를 호출하면 다음과 같은 오류가 발생한다.
원인 해결방법은 간단하다.
페이지 호출을 위해서 URL에 GET 방식으로 모든 도메인 주소를 작성하였지만, 호출해주는 메소드는 POST로 명시적인 지정이 되어 있기 때문이다.
1. @RequestMapping(value = "GetPost", method = RequestMethod.POST)
2. @RequestMapping(value = "GetPost", method = RequestMethod.GET)
public void GetPost(HttpServletRequest request, HttpServletResponse response) throws Exception {
}
현재 1번과 같이 RequestMapping이 선언되어 있을 것이다.
method 의 RequestMethod 부분을 POST에서 GET으로 바꿔준다.
그리고 다시 URL을 호출해본다.