Spring Boot - 计算用户请求

时间:2016-01-28 18:53:14

标签: spring spring-boot

我有一个HandlerInterceptor,它拦截了对Spring Boot应用程序的所有用户请求。我试图找到一种方法来保存来到应用程序的请求数。下面的地图总是打印大小为1,并且不会增加每个新请求。有人可以帮助我吗

public class UserLoggingInterceptor implements HandlerInterceptor  {

    private static HashMap<String,String> userManagement = new HashMap<String,String>();

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
        throws Exception {
        userManagement.put("Another User Added :- ", "1");
        System.out.println("userManagement.size() is "+userManagement.size());
        return true;
    }
} 

0 个答案:

没有答案