No mapping found for HTTP request with URI 에러 원인
1. web.xml 에서 DispatcherServlet 선언이 제대로 되어있는지 확인
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:/META-INF/spring/appServlet/servlet-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
2. servlet-context.xml 에 설정 확인
<context:component-scan base-package="com.test.pkg" use-default-filters="false">
<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
참고 : servlet-context에서는 controller annotation만 등록하고 나머지(service, repository, component 등)는 spring bean으로 등록하지 않는다.
use-default-filters="false" 로 설정하면 표기되지 않은 나머지(service, repository, component 등)는 spring bean으로 등록하지 않는다는 뜻이다.
3. url mapping이 잘 되어있는지 컨트롤러에서 확인
@RequestMapping( value="/login") 이런식으로 url이 제대로 mapping 되어있는지 확인한다.
추가로 컨트롤러에 제대로 컨트롤러 선언(@Controller)가 되어있는지도 확인!!
4. servlet-context.xml에 <mvc:annotation-driven /> 선언 확인
내 경우 이 부분이 빠져있어서 No mapping found for HTTP request with URI 에러가 발생했었다...바보같이...ㅠㅠ