chenguanwei 2010-03-23 17:08
浏览 249
已采纳

spring拦截器莫名其妙的拦截

使用Spring MVC
写了个拦截器用来拦截Controller中的方法:
@Override
public void before(Method method, Object[] args, Object target)
throws Throwable {
System.out.println("---------------");
System.out.println("method.getDeclaringClass().getName() = " + method.getDeclaringClass().getName());
System.out.println("method.getName()=" + method.getName());
System.out.println("----------------");

}

配置文件:



*Controller



btnInterceptor


但是运行观察控制台发现输出结果为:
[http-8080-1] DEBUG org.springframework.web.servlet.DispatcherServlet - DispatcherServlet with name 'app' processing

request for [/weboa/safe/buildFuncTree.do]

method.getDeclaringClass().getName() = java.lang.Object

method.getName()=toString

[http-8080-1] DEBUG org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping - Mapping

[/safe/buildFuncTree.do] to handler 'cn.edu.swu.oa.safe.controller.SafeController@571688'
[http-8080-1] DEBUG org.springframework.web.bind.annotation.support.HandlerMethodInvoker - Invoking request handler

method: public void cn.edu.swu.oa.safe.controller.SafeController.buildFuncTree

(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)

method.getDeclaringClass().getName() = cn.edu.swu.oa.safe.controller.SafeController

method.getName()=buildFuncTree

我不清楚

method.getDeclaringClass().getName() = java.lang.Object

method.getName()=toString

这部分是从哪来的,而且tomcat启动时也打印很多次这部分信息

  • 写回答

4条回答 默认 最新

  • wanghaolovezlq 2010-03-23 17:26
    关注

    那就得你自己写代码实现

    public void before(Method method, Object[] args, Object target)
    throws Throwable {
    这里你可以判断method.getName()为Object的那些方法时直接return
    System.out.println("---------------");
    System.out.println("method.getDeclaringClass().getName() = " + method.getDeclaringClass().getName());
    System.out.println("method.getName()=" + method.getName());
    System.out.println("----------------");

    }

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog