cooltange 发表于 2013-12-3 21:09:06

求助 spring mvc 高手 ,解决一个拦截器中HandlerMethod 的问题

在jeecg 里面 写了一个 自定义拦截器 想做个类似struts2的 token令牌 避免前台表单被重复提交,
打算在 controller中使用 自定义annotation,因此 需要 在拦截器中 访问controller中方法上的 annotation:

public class TokenInterceptor extends HandlerInterceptorAdapter {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
      if (handler instanceof HandlerMethod) {
            HandlerMethod handlerMethod = (HandlerMethod) handler;
            Method method = handlerMethod.getMethod();
            Token annotation = method.getAnnotation(Token.class);
       ......



但是 发现 handler对象 一直不是 HandlerMethod类型 的 实例, 感觉 和 jeecg的 配置有关系.

springmvc 不是很熟, 请相关的高手 指点迷津 , 感激涕零
页: [1]
查看完整版本: 求助 spring mvc 高手 ,解决一个拦截器中HandlerMethod 的问题