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

可以做书的网站上海网络推广方法

可以做书的网站,上海网络推广方法,附近找装修公司,黄页88网推广服务问题 因为最近这个项目没有调用链监控系统的支持#xff0c;但是#xff0c;本地PostMan调试的时候又需要请求头才能正常调试。 思路 喊ChatGPT实现一下能够打印所有请求头的拦截器#xff0c;然后#xff0c;集成到已有代码即可。 解决 RequestHeaderInterceptor.jav…问题 因为最近这个项目没有调用链监控系统的支持但是本地PostMan调试的时候又需要请求头才能正常调试。 思路 喊ChatGPT实现一下能够打印所有请求头的拦截器然后集成到已有代码即可。 解决 RequestHeaderInterceptor.java package cn.xxxx.interceptor;import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; import org.springframework.web.servlet.HandlerInterceptor;import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.util.Enumeration;/*** 打印接受到的所有请求头* author zhangyalin*/ Slf4j Component public class RequestHeaderInterceptor implements HandlerInterceptor {Overridepublic boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {// 获取所有请求头的名称EnumerationString headerNames request.getHeaderNames();while (headerNames.hasMoreElements()) {String headerName headerNames.nextElement();// 获取请求头的值并打印String headerValue request.getHeader(headerName);log.debug(headerName : headerValue);}return HandlerInterceptor.super.preHandle(request, response, handler);} } WebMvcConfiguration.java 在Springboot的配置类中集成上面的拦截器即可。 package cn.xxxx.config;import org.springframework.beans.factory.annotation.Value; import org.springframework.cloud.context.config.annotation.RefreshScope; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.core.Ordered; import org.springframework.web.servlet.config.annotation.CorsRegistry; import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;import javax.annotation.Resource;/*** 基础配置* author zhangyalin*/ RefreshScope ComponentScan({cn.xxxx, cn.xxx.sxa}) Configuration public class WebMvcConfiguration implements WebMvcConfigurer {Resourceprivate RequestHeaderInterceptor requestHeaderInterceptor;Value(${interceptors.requestHeaderInterceptor:false})private boolean requestHeaderInterceptorEnable;/*** 注入拦截器**/Overridepublic void addInterceptors(InterceptorRegistry registry) {if (requestHeaderInterceptorEnable){// 打印所有请求头registry.addInterceptor(requestHeaderInterceptor).order(Ordered.HIGHEST_PRECEDENCE).addPathPatterns(/**);}} } 配置中心 logging:level:cn.xxxx.interceptor: DEBUG interceptors:requestHeaderInterceptor: true总结 这就是简单使用HandlerInterceptor实现自己的请求头打印拦截器。我这里配置中心动态性还是不很完善。interceptors.requestHeaderInterceptor配置修改后得重启服务才能生效。
http://www.eeditor.cn/news/120310/

相关文章:

  • 聊城门户网站酒店 公司 安徽 网站建设
  • app网站及其特色python编程软件手机版下载
  • 临沂网站设计公司怎么查网站制作空间有效期
  • 哪个网站有手工活做创建网站的准备
  • 开源做网站需要申请账号吗芜湖市网站建设公司
  • 电子商务网站建设有什么认识中级网络工程师含金量
  • 深圳网站建设知名公司阿凡达做网站电话
  • 科技类网站模板桂林手机网站建设
  • 公积金网站建设模板网站开发顶岗周记
  • ai特效字体网站桂平逗乐游戏招聘网站开发
  • 网站改版 价格跨境电商那个网站做饰品比较好
  • 扬州做网站公司WordPress文章按钮
  • 可以做兼职翻译的网站做的网站没流量吗
  • cvm服务器做网站做网站应该了解什么问题
  • 基于网站开发的app特产网站建设的目的
  • 新旧网站对比乐清新闻综合频道直播
  • 象山经济开发区建设有限公司网站游戏平台网站制作
  • 外包网温州百度网站快速优化
  • 营销型网站建设区别用dw做音乐网站
  • 河北省建设工程安全生产网站白云区建网站公司
  • 3g手机网站建设个人简历生成器
  • 可以上传软件的网站太原本地网站搭建公司
  • 如何建设物流网站网站建设 贴吧
  • 相亲网站上做it的骗术沁水网站建设
  • 深圳做网站优化的公司wordpress图片评论
  • 智能建站系统cms互联网行业裁员
  • 网站建设预招标vps建设网站别人访问不了
  • 如何做网站管理首钢建设二建设公司网站
  • 织梦怎么修改网站logo天津小程序网站开发公司
  • 官方网站焊工证查询公司注册网站需要什么资料