Exception

The DispatcherServlet configuration needs to include a HandlerAdapter that supports this handler

Jungsoomin :) 2020. 8. 9. 20:14

출처는 역시 Stackoverflow.

 

해당 에러는 말그대로

DispatcherServlet 설정에 컨트롤러를 실행하는 HandlerAdapter..객체가 해당 handler=controller에 필요하다. 라는 이야기 같은데. 대부분 개발자의 @Controller 에노테이션이나, @RequestMapping 경로 설정 실수로 보인다.

 

마음이 급하던 바보인 내가 무슨 일을 했냐면..

@Controller(value = "/sample/*")
@Log4j
public class SampleController {
	
	@RequestMapping(value = "/file")
	public void uploadFile(ArrayList<MultipartFile> files) {
		files.forEach( f -> {
			log.info("file : "+f.getOriginalFilename());
			log.info("size : "+f.getSize());
		});
	}
}

@Controller 에노테이션의 속성값에 경로를 주고 있다...ㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠ

 

그리하여.. 


@RequestMapping 을 주어 경로설정을 다시 수정하니, ..음..아주아주 정상적으로 돌아간다. 방식처리도 하지 않고서 RequestMapping 붙이니 더욱 문제구나...싶었다. 반성한다...ㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠ

@Controller
@RequestMapping(value = "/sample/*")
@Log4j
public class SampleController {
	
	@RequestMapping(method = RequestMethod.GET, value = "/file")
	public void uploadFileView() {
		
	}
	
	@RequestMapping(method = RequestMethod.POST,value = "/file")
	public void uploadFile(ArrayList<MultipartFile> files) {
		files.forEach( f -> {
			log.info("file : "+f.getOriginalFilename());
			log.info("size : "+f.getSize());
		});
	}
}