spring index.html 관련 오류 문의 합니다

45 views
Skip to first unread message

Bosco Chang

unread,
May 14, 2019, 4:53:21 AM5/14/19
to Korea Spring User Group Q&A

spring MVC 프로젝트를 JavaConfig( xml 없는) 방식으로 연습하고 있습니다.

아래와 같이 config 파일을 생성했구요.

home.jsp 만 띄우도록 다른 부분은 추가 하지 않은 상태 입니다


public class AppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {

	@Override
	protected Class<?>[] getRootConfigClasses() {
		return new Class[] { RootConfig.class };
	}

	@Override
	protected Class<?>[] getServletConfigClasses() {
		return new Class[] { WebMvcConfig.class };
	}

	@Override
	protected String[] getServletMappings() {
		return new String[] { "/" };
	}
}


테스트 과정에서 좀 이상한 부분이 있어 문의 합니다


작성한 프로젝트에

webapp 폴더에 index.html 파일을 하나 생성하면

다음과 같이 작성한 mapper 즉 http://localhost:8080/context/  으로 요청을하면

404 오류가 나타 납니다.

원인을 몰라 헤메이다 index.html이 없으면 정상으로 나타 나는 것을 확인 했습니다.


	@RequestMapping(method=RequestMethod.GET,value="/")
	public String home(Model model) {
		
		// log.debug("Home Controller Method Home");
		return "home";
	}
	


getServletMapper 부분을 "*.do" 등의 다른 패턴으로 설정하면 문제가 없더군요

또는

index.html 파일을 지우고 index.jsp 파일을 webapp 폴더에 생성해 두면

index.jsp 파일이 열리는 것도 확인 했습니다.


어떤 이유인지 궁금해서 문의 글 남깁니다.


Reply all
Reply to author
Forward
0 new messages