Почему мой вызов перехватчика preHandle после метода контроллера - PullRequest
0 голосов
/ 10 сентября 2018

почему мой перехватчик звонит после контроллера

Мой Inteceptor

@Slf4j
@Component
public class LoggingInterceptor extends HandlerInterceptorAdapter {
 @Override
  public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
      throws Exception {
    System.out.println("Call Interceptor preHandle method");
    return true;
  }
}
    <mvc:interceptor>
        <mvc:mapping path="/*" />
        <mvc:exclude-mapping path="/index*" />
        <bean class="my.corp.LoggingInterceptor" />
    </mvc:interceptor>

Вот мой контроллер:

@RestController
@RequestMapping("/api")
public class TestApiController {

  @PostMapping("/test")
  public TestObject create(
      @RequestBody @Valid Student request) {
    System.out.println("Call controller method")
    return "";
  }
}

Но когда я отправляю запрос на /api/test.

Журнал:

Call controller method
Call Interceptor preHandle method

Я ожидал, что preHandle должен быть вызван до Контроллера, но, похоже, здесь что-то пошло не так

1 Ответ

0 голосов
/ 11 сентября 2018

Проблема заключается в следующем путь должен быть двойной звездой "/ **"

...