私のプロジェクトはSpring MVCに依存しており、リクエストをインターセプトするインターセプターを作成しました。リクエストからパラメーターを取得したいのですが、私のコードは次のとおりです。
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
HandlerMethod maControl = (HandlerMethod) handler;
Method pmrResolver = (Method) maControl.getMethod();
String methodName = pmrResolver.getName();
....
}
しかし、今では例外がスローされます:
java.lang.ClassCastException: org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler cannot be cast to org.springframework.web.method.HandlerMethod
例外の原因は何ですか?