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 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 用matlab 设计一个不动点迭代法求解非线性方程组的代码
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试