当前位置: 首页 > news >正文

网站推广适合哪种公司做网站链接收费怎么做的

网站推广适合哪种公司做,网站链接收费怎么做的,广告文案的100案例,wordpress 标签下的文章文章目录如何优雅的打印项目日志原理实现日志打印Filter注入容器如何优雅的打印项目日志 框架 springboot 原理 使用filter拦截请求#xff0c;打印出请求、响应#xff0c;及耗时 知识点 1、OncePerRequestFilter Filter base class that aims to guarantee a single … 文章目录如何优雅的打印项目日志原理实现日志打印Filter注入容器如何优雅的打印项目日志 框架 springboot 原理 使用filter拦截请求打印出请求、响应及耗时 知识点 1、OncePerRequestFilter Filter base class that aims to guarantee a single execution per request dispatch, on any servlet container.Filter base class that aims to guarantee a single execution per request dispatch, on any servlet container. 过滤器基类旨在保证在任何 servlet 容器上每个请求调度一次执行。兼容多种servlet版本保证在任何 servlet 容器上每个请求调度一次执行。 2、ContentCachingRequestWrapperContentCachingResponseWrapper HttpServletRequest 包装器用于缓存从输入流和读取器读取的所有内容并允许通过字节数组检索此内容。 源代码如下第一次获取输入流时复制了一份 因为request的数据流只能读取一次通过过滤器读取一次后后面的业务处理会读不到数据 通过ContentCachingRequestWrapper将请求包装可以进行多次读取 实现 继承OncePerRequestFilter重写doFilterInternal方法 日志打印Filter import com.google.common.base.Throwables; import lombok.extern.slf4j.Slf4j; import org.springframework.http.MediaType; import org.springframework.web.filter.OncePerRequestFilter; import org.springframework.web.util.ContentCachingRequestWrapper; import org.springframework.web.util.ContentCachingResponseWrapper;import javax.servlet.FilterChain; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.util.Enumeration;Slf4j public class LogFilter extends OncePerRequestFilter {private Integer printMaxSize;public LogFilter() {}public LogFilter(Integer printMaxSize) {if (printMaxSize null) {printMaxSize 1024;}this.printMaxSize printMaxSize;}Overrideprotected void doFilterInternal(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, FilterChain filterChain) throws ServletException, IOException {if (isAsyncDispatch(httpServletRequest)) {filterChain.doFilter(httpServletRequest, httpServletResponse);} else {doLogFilter(getRequestWrapper(httpServletRequest), getResponseWrapper(httpServletResponse), filterChain);}}private void doLogFilter(ContentCachingRequestWrapper requestWrapper, ContentCachingResponseWrapper responseWrapper, FilterChain filterChain) throws IOException, ServletException {StringBuilder sb new StringBuilder();sb.append(System.lineSeparator()).append(Method: [).append(requestWrapper.getMethod()).append(] ).append(URI: ).append(requestWrapper.getRequestURI()).append(System.lineSeparator());long start System.currentTimeMillis();filterChain.doFilter(requestWrapper, responseWrapper);try {sb.append(getParams(requestWrapper)).append(System.lineSeparator());sb.append(getBody(requestWrapper));sb.append(getResponse(responseWrapper)).append(System.lineSeparator());} catch (Exception e) {log.warn(日志打印失败 e:{}, Throwables.getStackTraceAsString(e));} finally {responseWrapper.copyBodyToResponse();long end System.currentTimeMillis();sb.append(use time :).append(end - start).append(ms);log.info(sb.toString());}}private String getBody(ContentCachingRequestWrapper requestWrapper) {StringBuilder sb new StringBuilder();String contentType requestWrapper.getContentType();if (requestWrapper.getMethod().equalsIgnoreCase(POST) (MediaType.APPLICATION_JSON_VALUE.equals(contentType)|| MediaType.APPLICATION_JSON_UTF8_VALUE.equals(contentType))) {sb.append(body: ).append(System.lineSeparator());sb.append(new String(requestWrapper.getContentAsByteArray(), StandardCharsets.UTF_8));sb.append(System.lineSeparator());}return sb.toString();}private String getResponse(ContentCachingResponseWrapper responseWrapper) {String responseStr new String(responseWrapper.getContentAsByteArray(), StandardCharsets.UTF_8);responseStr responseStr.length() printMaxSize ? responseStr.substring(0, printMaxSize) : responseStr;return response: responseStr;}private String getParams(ContentCachingRequestWrapper requestWrapper) {EnumerationString enumeration requestWrapper.getParameterNames();StringBuilder sb new StringBuilder();sb.append(params: );while (enumeration.hasMoreElements()) {String paramName enumeration.nextElement();sb.append(paramName);sb.append( : );sb.append(requestWrapper.getParameter(paramName));sb.append(, );}if (sb.length() 2) {sb.replace(sb.length() - 2, sb.length(), );}return sb.toString();}private ContentCachingResponseWrapper getResponseWrapper(HttpServletResponse httpServletResponse) {if (httpServletResponse instanceof ContentCachingResponseWrapper) {return (ContentCachingResponseWrapper) httpServletResponse;} else {return new ContentCachingResponseWrapper(httpServletResponse);}}private ContentCachingRequestWrapper getRequestWrapper(HttpServletRequest httpServletRequest) {if (httpServletRequest instanceof ContentCachingRequestWrapper) {return (ContentCachingRequestWrapper) httpServletRequest;} else {return new ContentCachingRequestWrapper(httpServletRequest, printMaxSize);}} } 注入容器 Configuration public class FilterConfig {/*** 日志长度限制*/private Integer printMaxSize 1024;Beanpublic LogFilter getLogFilter() {return new LogFilter(printMaxSize);}}
http://www.w-s-a.com/news/958360/

相关文章:

  • 创建门户网站一页网站首页图如何做
  • 服装手机商城网站建设sns社交网站有哪些
  • 无锡工程建设招标网站怎么自己建设公司网站
  • 哪个网站可以学做咸菜安卓软件开发需要学什么软件
  • 自有网站建设的团队遂宁市建设局网站
  • 网站建设哪个好一些网站内容导出
  • 什么网站的页面做的比较好看网上做平面设计的网站
  • 网站建设单选网站建设学校培训学校
  • 可以做app的网站logo设计在线生成免费标小智
  • 网站变更备案做酒类网站
  • 网站必须要备案吗东莞市非凡网站建设
  • 太原建网站公司网站设计的流程是怎样的
  • 网站开发交易平台北京网站建设的价格低
  • 捷克注册公司网站搜索引擎广告推广
  • 网站的实用性青岛九二网络科技有限公司
  • 广东备案网站网站反链如何做
  • 做网站的实施过程企业建设H5响应式网站的5大好处6
  • ps制作个人网站首页景安搭建wordpress
  • 常德建设网站制作网站建设推广是什么工作
  • 长春服务好的网站建设百度推广话术全流程
  • 做的网站浏览的越多越挣钱基于jsp的网站开发开题报告
  • 好的做问卷调查的网站好网站调用时间
  • 广州微网站建设平台阿里云国外服务器
  • 如何把做好的网站代码变成网页wordpress shortcode土豆 视频
  • 网站改版竞品分析怎么做中山网站建设文化价格
  • 玉林市网站开发公司电话做网站空间 阿里云
  • 南充做网站略奥网络免费的正能量视频素材网站
  • 电子商务网站开发的基本原则汕头网站制作流程
  • 网站访问量突然增加合肥宣传片制作公司六维时空
  • 建设购物网站流程图怎么找网站