* @author 韩超@bksx 2018/1/25 11:17*/@Overridepublic void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, @Nullable Exception ex) throws Exception {//如果是方法请求,则进行统计if (handler instanceof HandlerMethod){//获取方法用时Long now = System.currentTimeMillis();Long useTime = now - startTime.get();//格式化当前日期SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");String endTime = sdf.format(new Date(now));//获取URIString uri = request.getRequestURI();//获取请求类型 POST 、PUT 、GET等等String type = request.getMethod();//组合信息StringBuffer sb = new StringBuffer();sb.append("========{").append(endTime).append(",URI = [").append(uri).append("],method = ").append(true).append(",").append("Use Time : ").append(useTime).append(" 毫秒}\n");LOGGER.info(sb.toString());}}}
3.4.-mvc-.xml
3.5.
三种类型的请求日志:无参数、GET请求、POST请求
2018-01-26 15:37:12 INFORequestInfoHandlerInterceptor:75 - --------------------------------------------------------------------------------2018-01-26 15:37:12------------------------------------------------------------------------------------------Controller:pers.hanchao.hespringmvc.interceptors.LoginController----------Method:[public java.lang.String pers.hanchao.hespringmvc.interceptors.LoginController.login(javax.servlet.http.HttpServletRequest,pers.hanchao.hespringmvc.interceptors.User,org.springframework.ui.Model)----------Parameters:----------URI:[/login-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------2018-01-26 15:37:12 INFORequestInfoHandlerInterceptor:103 - ========{2018-01-26 15:37:12,URI = [/login],method = true,Use Time : 3 毫秒}2018-01-26 15:37:18 INFORequestInfoHandlerInterceptor:75 - --------------------------------------------------------------------------------2018-01-26 15:37:18------------------------------------------------------------------------------------------Controller:pers.hanchao.hespringmvc.requestannotation.RequestAnnotationController----------Method:[public java.lang.String pers.hanchao.hespringmvc.requestannotation.RequestAnnotationController.postRequestParam(java.lang.String,org.springframework.ui.Model)----------Parameters:postname=%E6%9D%8E%E5%9B%9B----------URI:[/requestannotation/postrequestparam-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------2018-01-26 15:37:18 INFORequestInfoHandlerInterceptor:103 - ========{2018-01-26 15:37:18,URI = [/requestannotation/postrequestparam],method = true,Use Time : 5 毫秒}2018-01-26 15:37:42 INFORequestInfoHandlerInterceptor:75 - --------------------------------------------------------------------------------2018-01-26 15:37:42------------------------------------------------------------------------------------------Controller:pers.hanchao.hespringmvc.requestannotation.RequestAnnotationController----------Method:[public pers.hanchao.hespringmvc.requestannotation.User pers.hanchao.hespringmvc.requestannotation.RequestAnnotationController.postRequestBody(pers.hanchao.hespringmvc.requestannotation.User)----------Parameters:{"name":"张三","sex":"男"}----------URI:[/requestannotation/requestbody-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------2018-01-26 15:37:42 INFORequestInfoHandlerInterceptor:103 - ========{2018-01-26 15:37:42,URI = [/requestannotation/requestbody],method = true,Use Time : 20 毫秒}
- 一 构建SpringCloud 项目初始环境
- [开发环境]支持MASM代码汇编开发环境,支持32位和64位XP/7/8
- 一 YOLOv3:Darknet代码解析安装Darknet
- 语言模型2:二元文法求句子概率代码
- matplotlib可视化:基础绘图函数使用【函数功能+案例代码】
- Spring Cloud底层原理与核心组件
- Spring Cloud核心组件工作原理
- Spring-Cloud核心组件及底层原理
- ASGNet论文和代码解读
- Spring4-快速入门之在IOC容器中装配Bean