Fix NullPointer Exception

This commit is contained in:
小海
2019-12-04 15:54:45 +08:00
parent 9a4a930426
commit 1745a5d821

View File

@@ -21,7 +21,11 @@ public class VisitorRecord implements HandlerInterceptor {
@Override @Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
HttpSession session = request.getSession(); HttpSession session = request.getSession();
HashMap<String, Integer> visitDetail = (HashMap<String, Integer>) session.getAttribute("visitDetail"); HashMap<String, Integer> visitDetail = (HashMap<String, Integer>) session.getAttribute("visitDetail");
if (visitDetail == null) {
return true;
}
// 获取访问次数 // 获取访问次数
Integer count = visitDetail.get(RequestUtil.getCompleteUrlAndMethod(request)); Integer count = visitDetail.get(RequestUtil.getCompleteUrlAndMethod(request));
// 自增 // 自增