Giter Club home page Giter Club logo

log-incoming-request's Introduction

Spring Boot Runtime

This module contains articles about administering a Spring Boot runtime

Relevant Articles:

感想:

  1. 要实现在请求中记录时间的需求,可以通过HandlerInterceptorAdapter继承的办法, 在preHandle记录开始时间,在afterCompletion记录结束的时间,前后两个时间相减得到运行时间。另一种设置记录时间的方法是用threadlocal往request里设置字段的办法。

  2. 原文中先使用Interceptor,然后使用filter, 这样做的原因是对于非x-www-form-urlencoded的post请求体, 只能用getInputStream()获取流的具体内容。这里有个问题,而getInputStream()输入请求的流只能读取一次。 如果想实现流的多次读取, 就要把流写回去,就只能用到filter了,在这里用的是springboot提供的CommonsRequestLoggingFilter (通用请求日志过滤器)。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.