小编Nis*_*obi的帖子

Spring启动应用程序:http响应时间的负值

我根据这项技术开发了一个Web应用程序.

  1. 弹簧靴(底部起动器):1.4.2
  2. Java 7
  3. 操作系统:Centos
  4. Servlet过滤器:org.spring.web.filter.OncePerRequestFilter

在步骤4中,过滤器用于打印http请求/响应信息日志.这些数据包括:

  • (a)http url
  • (b)请求机构
  • (c)回应机构
  • (d)回应时间.

问题出现在(d)响应时间.但是,大部分响应时间都可以.但是对于少数http请求和反应,我发现具有负响应时间的日志(例如-1024ms).

这里我在Servlet Filter中手动计算了http响应时间

protected void doFilterInternal(...){

  long startTime = System.currentTimeMillis();
  ..
  some code
  filterChain.doFilter(httpRequest,httpResonse);
  ...
  long endTime = System.currentTimeMillis();
  long responseTime = endTime  - startTime
  log.debug(responseTIme); [SLF4J logger,logback.xml]

}
Run Code Online (Sandbox Code Playgroud)

java spring servlet-filters spring-boot undertow

7
推荐指数
1
解决办法
121
查看次数

标签 统计

java ×1

servlet-filters ×1

spring ×1

spring-boot ×1

undertow ×1