개인 공부 상자/오류 해결

Request method 'GET' not supported 오류

RSpring41 2021. 8. 25. 20:20

해당 오류는 GET방식으로 접속을 시도하는데 Controller에

 

@PostRequest(valuse = "/url") 또는 @RequestMapping(value="/url", method=RequestMethod.POST)

 

으로 선언되어 있어 Get방식이 지원되지 않는다는 오류다.

 

위 코드를 아래중에 하나로 수정해서 사용하면 된다.

 

@GetRequest (추천)

@RequestMapping(value="/url", method=RequestMethod.GET)

@RequestMapping(value="/url") 

 

 


 

여기 아래에서 원하는거 골라서 사용하면 된다.

// Get방식
@RequestMapping(value = "/user", method = RequestMethod.GET)
public String user() {
  // 데이터 처리 
  return "user";
}

// Post방식
@RequestMapping(value = "/user", method = RequestMethod.POST)
public String user() {
  // 데이터 처리 
  return "user";
}


// Get방식
@GetRequest(value = "/user"){
public String user() {
  // 데이터 처리 
  return "user";
}

// Post방식
@PostRequest(value = "/user"){
public String user() {
  // 데이터 처리 
  return "user";
}


// 둘다 받기
@RequestMapping(value = "/user")
public String user() {
  // 데이터 처리 
  return "user";
}