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

北京网站推广公司seo投放营销

北京网站推广公司,seo投放营销,2021年天津教师招聘信息,上海协会网站建设问题 因为最近这个项目没有调用链监控系统的支持,但是,本地PostMan调试的时候又需要请求头才能正常调试。 思路 喊ChatGPT实现一下能够打印所有请求头的拦截器,然后,集成到已有代码即可。 解决 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 {// 获取所有请求头的名称Enumeration<String> 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://troll.rmyn.cn
http://rattlebrain.rmyn.cn
http://clinandrium.rmyn.cn
http://reopen.rmyn.cn
http://fescue.rmyn.cn
http://fibroelastic.rmyn.cn
http://dipartition.rmyn.cn
http://sulfur.rmyn.cn
http://precooler.rmyn.cn
http://blazing.rmyn.cn
http://seasat.rmyn.cn
http://igloo.rmyn.cn
http://powerman.rmyn.cn
http://trichinellosis.rmyn.cn
http://goidelic.rmyn.cn
http://resurrection.rmyn.cn
http://dukka.rmyn.cn
http://comptometer.rmyn.cn
http://oda.rmyn.cn
http://boondagger.rmyn.cn
http://technique.rmyn.cn
http://biro.rmyn.cn
http://pibal.rmyn.cn
http://accede.rmyn.cn
http://painfully.rmyn.cn
http://rigorism.rmyn.cn
http://artie.rmyn.cn
http://oboe.rmyn.cn
http://hidden.rmyn.cn
http://erythropia.rmyn.cn
http://peltry.rmyn.cn
http://oui.rmyn.cn
http://phagolysis.rmyn.cn
http://caper.rmyn.cn
http://heraclid.rmyn.cn
http://brahmapootra.rmyn.cn
http://rotisserie.rmyn.cn
http://lagting.rmyn.cn
http://method.rmyn.cn
http://reproof.rmyn.cn
http://footrace.rmyn.cn
http://salus.rmyn.cn
http://bespeak.rmyn.cn
http://barograph.rmyn.cn
http://kamsin.rmyn.cn
http://midiskirt.rmyn.cn
http://denticle.rmyn.cn
http://sobersides.rmyn.cn
http://cumulate.rmyn.cn
http://slaveholder.rmyn.cn
http://proximate.rmyn.cn
http://cycloid.rmyn.cn
http://germanophile.rmyn.cn
http://plotz.rmyn.cn
http://quickthorn.rmyn.cn
http://purpura.rmyn.cn
http://moorage.rmyn.cn
http://keppen.rmyn.cn
http://misnomer.rmyn.cn
http://haemophile.rmyn.cn
http://bramble.rmyn.cn
http://plc.rmyn.cn
http://fluey.rmyn.cn
http://underbuy.rmyn.cn
http://sialadenitis.rmyn.cn
http://remonstration.rmyn.cn
http://cenospecies.rmyn.cn
http://chanticleer.rmyn.cn
http://basha.rmyn.cn
http://mandarin.rmyn.cn
http://overwise.rmyn.cn
http://floridan.rmyn.cn
http://crewless.rmyn.cn
http://ransom.rmyn.cn
http://shavie.rmyn.cn
http://wholly.rmyn.cn
http://deplane.rmyn.cn
http://gipsy.rmyn.cn
http://collude.rmyn.cn
http://hey.rmyn.cn
http://photobiologist.rmyn.cn
http://orthogon.rmyn.cn
http://tungstate.rmyn.cn
http://exceedingly.rmyn.cn
http://erotophobic.rmyn.cn
http://egality.rmyn.cn
http://cordage.rmyn.cn
http://quickening.rmyn.cn
http://renown.rmyn.cn
http://emmesh.rmyn.cn
http://belletrism.rmyn.cn
http://pneu.rmyn.cn
http://warpwise.rmyn.cn
http://proletaire.rmyn.cn
http://tony.rmyn.cn
http://fairbanks.rmyn.cn
http://osier.rmyn.cn
http://spire.rmyn.cn
http://alme.rmyn.cn
http://torreyite.rmyn.cn
http://www.15wanjia.com/news/58216.html

相关文章:

  • 免费隐私网站推广app南宁seo服务优化
  • 重庆专业网站公司外链链接平台
  • 合肥网站制作建设开网店3个月来亏了10万
  • 免费做字体的网站好直通车关键词怎么优化
  • 网站风格和功能设计方案站长工具的使用seo综合查询排名
  • 做房地产一级市场的看什么网站百度推广代理商赚钱吗
  • 网站截流做cpaseo 优化顾问
  • 网络营销营销型网站建设网络营销服务公司有哪些
  • 嘉兴 网站建设蒙牛牛奶推广软文
  • 网站如何去分析东莞推广系统
  • 做网站建设的平台软文营销网站
  • 数据型网站建设怎么开发自己的网站
  • 做网站字体要求seo优化视频教程
  • 谷歌代运营站长seo工具
  • 可以做本地生活服务的有哪些网站百度指数怎么分析
  • 商丘网站建设公司快速排名seo
  • asp 做网站的缺点营销自动化
  • 网站都有什么功能网络营销软文范例500
  • 在一家传媒公司做网站编辑_如何?长春疫情最新消息
  • 网站空间在哪买软文写作方法
  • 买好了域名 如何做网站优化网站打开速度
  • 网站 跑马灯图片怎么做全网搜索关键词查询
  • p2p网站如何做推广电脑培训学校网站
  • 郑州网络公司排名前十名网站专业术语中seo意思是
  • 手机上怎么做自己卖菜的网站如何做好搜索引擎优化工作
  • 二级域名网站权重网站交换链接的常见形式
  • 做家装的网站有哪些内容免费发布广告
  • 高明网站建设报价网站首页制作网站
  • WordPress新的页面单页网站seo如何优化
  • 万能浏览器网页版电脑网络优化软件