I followed the documentation for HandlerInterceptors. Noting that in the new version of Spring: "the configured interceptor will apply to all requests handled with annotated controller methods".
The following is in an xml configuration file:
I have an annotated controller beginning like this:
When I request a url that executes the controller's code, my interceptor code is never called. Can anyone please explain why?
The interceptor code is:
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
public class DomainNameInterceptor extends HandlerInterceptorAdapter {
public boolean preHandle(HttpServletRequest request,
HttpServletResponse response, Object handler)
throws Exception {
System.out.println("Why is this not called?");
return true;
}
}
I was using the following documentation: Spring Core 3.1.x Documentation
I did a search for HandlerInterceptor and followed the example given within the documentation in the included link.