티스토리 뷰

Spring Framework

No mapping found for HTTP request with URI 에러 원인

일상의 기록을 남긴다 2017. 10. 11. 10:42

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 에러가 발생했었다...바보같이...ㅠㅠ




공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함