无法读取Ojbect属性,始终为null

时间:2018-12-02 12:44:59

标签: java mysql

我有一个SpringMVC网络应用程序,我在Object property中设置了HandlerInterceptorAdapter的值:

public class SpringMVCFilter extends HandlerInterceptorAdapter {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        Interceptor.ss = "foo"; // it's a static field
        return super.preHandle(request, response, handler);
    }
...more code hidden
}

然后,我在MySQL QueryInterceptor中得到了值:

public class Interceptor implements QueryInterceptor {
    public static String ss = null;
    @Override
    public <T extends Resultset> T postProcess(Supplier<String> sql, Query interceptedQuery, T originalResultSet, ServerSession serverSession) {
        System.out.println(ss); // I have set the value for 'ss' before
        return null;
    }
...more code hidden
}

ss显然是一个静态变量,我给它分配了一个值,为什么我不能在QueryInterceptor中获得该值,它们在某个线程中,但是{{1} }始终显示ss,执行顺序首先分配。

环境:
mysql:mysql-connector-java:8.0.13
春季靴子2.0.2.RELEASE

0 个答案:

没有答案