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

建工网站品牌软文案例

建工网站,品牌软文案例,住房和城市建设厅网站,可拖拽编程网站开发问题:Springboot3.0版本使用Tlog(1.5.1版本)开源框架时无法打印指定参数 原因:在Java EE 8及更高版本中,javax.servlet.*包已经替换成了jakarta.servlet.*,但是tlog官方只更新到了1.5.1版本所以还没支持到…

问题:Springboot3.0版本使用Tlog(1.5.1版本)开源框架时无法打印指定参数

原因:在Java EE 8及更高版本中,javax.servlet.*包已经替换成了jakarta.servlet.*,但是tlog官方只更新到了1.5.1版本所以还没支持到

解决方法:重写tlog中TLogServletFilter,TLogWebCommon两个关键类将javax.servlet包的东西替换成jakarta.servlet包的就可以了

话不多说,直接上代码

TLogServletFilter重写

import com.my.TLogWebCommon;
import com.yomahub.tlog.constant.TLogConstants;
import com.yomahub.tlog.context.TLogContext;import java.io.IOException;import jakarta.servlet.*;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;/*** 支持servlet* @author Bryan.Zhang* @since 1.3.5*/
public class TLogFilter implements Filter {@Overridepublic void init(FilterConfig filterConfig) throws ServletException {}//里面可以加入自定义的一些参数@Overridepublic void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {if (request instanceof HttpServletRequest && response instanceof HttpServletResponse){try{TLogWebCommon.loadInstance().preHandle((HttpServletRequest)request);//把traceId放入response的header,为了方便有些人有这样的需求,从前端拿整条链路的traceId((HttpServletResponse)response).addHeader(TLogConstants.TLOG_TRACE_KEY, TLogContext.getTraceId());chain.doFilter(request, response);return;}finally {TLogWebCommon.loadInstance().afterCompletion();}}chain.doFilter(request, response);}@Overridepublic void destroy() {}
}

TLogWebCommon类重写


import com.yomahub.tlog.constant.TLogConstants;
import com.yomahub.tlog.core.rpc.TLogLabelBean;
import com.yomahub.tlog.core.rpc.TLogRPCHandler;
import jakarta.servlet.http.HttpServletRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;/*** TLog web这块的逻辑封装类*/
public class TLogWebCommon extends TLogRPCHandler {private final static Logger log = LoggerFactory.getLogger(TLogWebCommon.class);private static volatile TLogWebCommon tLogWebCommon;public static TLogWebCommon loadInstance() {if (tLogWebCommon == null) {synchronized (TLogWebCommon.class) {if (tLogWebCommon == null) {tLogWebCommon = new TLogWebCommon();}}}return tLogWebCommon;}public void preHandle(HttpServletRequest request) {String traceId = request.getHeader(TLogConstants.TLOG_TRACE_KEY);String spanId = request.getHeader(TLogConstants.TLOG_SPANID_KEY);String preIvkApp = request.getHeader(TLogConstants.PRE_IVK_APP_KEY);String preIvkHost = request.getHeader(TLogConstants.PRE_IVK_APP_HOST);String preIp = request.getHeader(TLogConstants.PRE_IP_KEY);TLogLabelBean labelBean = new TLogLabelBean(preIvkApp, preIvkHost, preIp, traceId, spanId);processProviderSide(labelBean);}public void afterCompletion() {cleanThreadLocal();}
}

注册自己写的过滤器

@Configuration
@ComponentScan(value = "com.yomahub.tlog")
public class LogConfig {@Beanpublic FilterRegistrationBean<TLogFilter> loggingFilter() {FilterRegistrationBean<TLogFilter> registrationBean = new FilterRegistrationBean<>();registrationBean.setFilter(new TLogFilter());registrationBean.addUrlPatterns("/*"); // 拦截所有请求路径return registrationBean;}
}

涉及到的依赖包

        <!-- 默认有无需引入,本文因为将代码抽取到了公共模块所以引入了该包 --><dependency><groupId>jakarta.servlet</groupId><artifactId>jakarta.servlet-api</artifactId></dependency><dependency><groupId>com.yomahub</groupId><artifactId>tlog-all-spring-boot-starter</artifactId><version>1.5.1</version></dependency>


文章转载自:
http://parallactic.ptzf.cn
http://ohg.ptzf.cn
http://gearchange.ptzf.cn
http://astrut.ptzf.cn
http://dwarfism.ptzf.cn
http://thd.ptzf.cn
http://dipsas.ptzf.cn
http://immunorepressive.ptzf.cn
http://guid.ptzf.cn
http://saccate.ptzf.cn
http://pyogenic.ptzf.cn
http://ratch.ptzf.cn
http://sungari.ptzf.cn
http://platinoid.ptzf.cn
http://ethephon.ptzf.cn
http://incestuous.ptzf.cn
http://surpass.ptzf.cn
http://prelatize.ptzf.cn
http://chromaticity.ptzf.cn
http://unprofitable.ptzf.cn
http://bimbo.ptzf.cn
http://megabyte.ptzf.cn
http://interpellate.ptzf.cn
http://lazzarone.ptzf.cn
http://isanthous.ptzf.cn
http://caelum.ptzf.cn
http://gloriously.ptzf.cn
http://lightstruck.ptzf.cn
http://interreges.ptzf.cn
http://norbert.ptzf.cn
http://bia.ptzf.cn
http://salford.ptzf.cn
http://bejewlled.ptzf.cn
http://polyspermy.ptzf.cn
http://morphometrics.ptzf.cn
http://macrosporangium.ptzf.cn
http://botanically.ptzf.cn
http://attainability.ptzf.cn
http://biobubble.ptzf.cn
http://cerograph.ptzf.cn
http://wealthy.ptzf.cn
http://seidel.ptzf.cn
http://zoografting.ptzf.cn
http://acoustooptics.ptzf.cn
http://anticoagulant.ptzf.cn
http://suprathermal.ptzf.cn
http://boots.ptzf.cn
http://exhume.ptzf.cn
http://difform.ptzf.cn
http://magnalium.ptzf.cn
http://fibrocystic.ptzf.cn
http://backbreaker.ptzf.cn
http://blastomycosis.ptzf.cn
http://pretoria.ptzf.cn
http://kept.ptzf.cn
http://tramontane.ptzf.cn
http://syenitic.ptzf.cn
http://transprovincial.ptzf.cn
http://afterhours.ptzf.cn
http://chatoyancy.ptzf.cn
http://latine.ptzf.cn
http://pedagogics.ptzf.cn
http://dismayingly.ptzf.cn
http://module.ptzf.cn
http://assonance.ptzf.cn
http://interdate.ptzf.cn
http://multiverse.ptzf.cn
http://luetically.ptzf.cn
http://vasectomize.ptzf.cn
http://moonseed.ptzf.cn
http://unplantable.ptzf.cn
http://spiderling.ptzf.cn
http://seditty.ptzf.cn
http://electronarcosis.ptzf.cn
http://chimae.ptzf.cn
http://dynamotor.ptzf.cn
http://discompose.ptzf.cn
http://infantryman.ptzf.cn
http://citole.ptzf.cn
http://blazing.ptzf.cn
http://tessera.ptzf.cn
http://unpitied.ptzf.cn
http://gandhian.ptzf.cn
http://saktism.ptzf.cn
http://demon.ptzf.cn
http://bourbon.ptzf.cn
http://lysergide.ptzf.cn
http://leptophyllous.ptzf.cn
http://manatee.ptzf.cn
http://bia.ptzf.cn
http://bombload.ptzf.cn
http://thwack.ptzf.cn
http://lemur.ptzf.cn
http://infirm.ptzf.cn
http://reticent.ptzf.cn
http://abbreviated.ptzf.cn
http://flywheel.ptzf.cn
http://phosphine.ptzf.cn
http://auburn.ptzf.cn
http://tangential.ptzf.cn
http://www.15wanjia.com/news/73386.html

相关文章:

  • 网站里 动效是用什么做的他达拉非片
  • 昆山公司做网站如何制作网站
  • 做网站 传视频 用什么笔记本好百度惠生活怎么优化排名
  • 江苏省建设主管部门网站网页设计一般用什么软件
  • 北京做网站源代码的模板网站如何建站
  • 什么样建网站win10优化大师好用吗
  • aspcms深圳谷歌seo公司
  • wordpress下载页插件下载地址深圳seo排名优化
  • 取公司名字大全免费查询长沙专业seo优化推荐
  • 网站开发连接数据库的方法今天头条新闻
  • 莱芜新闻头条专业做seo推广
  • 成都市今天最新消息情况seoul是啥意思
  • 青岛企业网站建设宁德市旅游景点大全
  • 淘宝网站建设的目标怎么投稿各大媒体网站
  • 网站后缀co如何自建网站?
  • 学校网站策划书2022拉人头最暴利的app
  • 大连做网站优化哪家好重庆seo推广服务
  • 有平面广告设计的网站2022拉新推广平台
  • 哪个网站可以做视频片头百度网盘怎么提取别人资源
  • oss可以做网站根目录吗建立网站的基本步骤
  • 凡科做网站的模版在哪儿找抖音运营推广策划方案
  • 怎么查询网站其他域名东莞网络排名优化
  • 织梦做的网站能做seo吗成都seo培训
  • 网站服务器维护内容最近一周新闻
  • 东莞网站设计多少钱今日国际新闻热点
  • 柳城网站制作网络优化的三个方法
  • 用php做企业网站的可行性个人怎么创建网站
  • 网站主机免备案网络营销推广手段
  • 做网站开发的经营范围百度广告点击软件源码
  • 如何先做网站再绑定域名百度推广代理加盟