첫번째로 프론트와 컨트롤러에 Post로 설정되어있는지 확인해줘야한다.

Controller에 분명 method=RequestMethod.POST 라고 설정되어 있고 

@ResponseBody
@RequestMapping(value = "/reg", method = RequestMethod.POST)
	public Map<String, Object> test() {
		return null 
}

 

프론트단에서 보낼때도 분명 POST 방식으로 보냈는데 

$.post("/reg", $frm.serialize(), function(data, textStatus){
	if(textStatus =="success") { 
		$("#res").text(data.res); 		
	}
});

 

Request method 'POST' not supported 에러가 난다면 

SpringSecurity를 확인해봐야한다. .

csrf 설정이 되어있으면 요청할때 csrf 값을 보내줘야하는데 없어으면 위와같이 발생된 에러임.. 

config 파일에 아래처럼 disable 처리해준다. 

http.authorizeRequests().csrf().disable()

 

적용하고 다시 실행해보기! 

+ Recent posts