나는 다음과 같은 한 인터셉터 클래스를 실행하지 않습니다스프링 MVC 핸들러 인터셉터가
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd">
<mvc:annotation-driven/>
<mvc:interceptors>
<mvc:interceptor>
<mvc:mapping path="/rest/api/01/status" />
<bean class="cz.coffeeexperts.feedback.server.web.interceptors.RestAuthorizationInterceptor" />
</mvc:interceptor>
</mvc:interceptors>
</beans>
을 그러나 내가 http://localhost:8080/myserver/rest/api/01/status
에 갈 때, 나는 상태 코드 200 (인터셉터를 추가하기 전과 동일)에 대한 정규 응답을 얻는다. 또한 메시지 "fuu"는 인쇄되지 않습니다 (따라서 preHandle 메소드가 호출되지 않습니다).
아이디어가 있으십니까? 나는이 예제로 시작했다 : http://javapapers.com/spring/spring-mvc-handler-interceptor/,하지만 다른 모든 예제는 똑같아 보인다, 내가 잘못 갈 수는 없다.
나는 봄 3.2.4.RELEASE
중요 편집을 사용하고,이 작동 :
<mvc:interceptors>
<mvc:interceptor>
<mvc:mapping path="/**" />
<bean class="cz.coffeeexperts.feedback.server.web.interceptors.RestAuthorizationInterceptor" />
</mvc:interceptor>
</mvc:interceptors>
그래서 질문은, 내 길 잘못 무엇입니까? 내 경로가 다음과 같이 정의되어 있기 때문에
모든 로그 ? 오류? 그것의 prehandle로서, 응답은 당신의 정상적인 컨트롤러 메소드에 의해 무시 될 것입니다 - prehandle은 일반적으로 요청을 처리하기위한 것입니다. – NimChimpsky
아무 일도 일어나지 않고 오류도없고 메서드도 호출되지 않습니다 (어떻게 말했는지, System.out.println ("fuu")에 대한 결과는 나타나지 않습니다). 또한 preHandle에 false를 반환하면 컨트롤러 메서드를 가로 챌 것입니다 ... – libik
매핑을 제거 할 때 인터셉터가 작동합니까? – geoand