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

福州网站建设新闻排名软件

福州网站建设新闻,排名软件,广告设计模板免费,介绍自己的网页设计作品问题记录:测试环境接口报错,日志里没有请求参数等信息,于是写了一个切面,但切面中获取不到 request的请求体,因为 post 请求体只能被消费一次,于是找解决办法 解决方法 既然 request 被消费了导致对应的请…

问题记录:测试环境接口报错,日志里没有请求参数等信息,于是写了一个切面,但切面中获取不到 request的请求体,因为 post 请求体只能被消费一次,于是找解决办法

解决方法

既然 request 被消费了导致对应的请求体没了,虽然 request 没了,但接收参数的实体类还在

解决:LocalVariableTableParameterNameDiscoverer.getParameterNames(Method method)
解释:见名知意, “本地变量表” 也就是常说的 局部变量表,获取对应请求参数
源码中的流程:获取方法所属的类->反射获取字节码->解析字节码获取->n部操作获取参数(无非是解析字节码)
脑子发热在想:请求一直在发,局部变量表的参数也会一直改变,并发环境下是否存在问题?
   没有问题,获取参数名称的过程是基于字节码的静态分析,即使同时处理 n 个请求,在那一刻的字节码是不会改变的

切面类

@Slf4j
@Aspect
@Component
public class ErrorLoggingAspect {@Pointcut("@annotation(com.test.conf.aspect.anon.ErrorLogging)")public void loggingAnon() {}@AfterThrowing("loggingAnon()")public void doAfterThrowing(JoinPoint joinPoint) throws IOException {// 接收到请求,记录请求内容ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();HttpServletRequest request = attributes.getRequest();MethodSignature signature = (MethodSignature) joinPoint.getSignature();String requestInfo = getRequestInfo(joinPoint,request,signature);BufferedWriter writer = new BufferedWriter(new FileWriter("/home/www/log/errorData.log", true));writer.write(requestInfo);writer.newLine();writer.newLine();writer.flush();}private String getRequestInfo(JoinPoint joinPoint, HttpServletRequest request, MethodSignature signature) {StringBuffer info = new StringBuffer();Method method = signature.getMethod();// 记录下请求内容info.append("异常时间:").append(DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss"));info.append("\n请求IP  : ").append(request.getRemoteAddr()).append("\n请求类型 :").append(request.getMethod()).append("\n请求URL : ").append(request.getRequestURI());if ("POST".equals(request.getMethod())) {LocalVariableTableParameterNameDiscoverer u = new LocalVariableTableParameterNameDiscoverer();String[] paramNames = u.getParameterNames(method);//方法 1 请求的方法参数值 JSON 格式 null不显示if (joinPoint.getArgs().length > 0) {Object[] args = joinPoint.getArgs();for (int i = 0; i < args.length; i++) {//请求参数类型判断过滤,防止JSON转换报错if (args[i] instanceof HttpServletRequest || args[i] instanceof HttpServletResponse || args[i] instanceof MultipartFile) {continue;}info.append("\n请求参数").append(paramNames[i]).append(" :").append(JSON.toJSONString(args[i]));}}} else {//请求的方法参数值 兼容fromDate格式和JSON格式Object[] args = joinPoint.getArgs();// 请求的方法参数名称 显示所有字段 值为null也显示该字段LocalVariableTableParameterNameDiscoverer u = new LocalVariableTableParameterNameDiscoverer();String[] paramNames = u.getParameterNames(method);if (args != null && paramNames != null) {StringBuilder params = new StringBuilder();for (int i = 0; i < args.length; i++) {//请求参数类型判断过滤,if (args[i] instanceof HttpServletRequest || args[i] instanceof HttpServletResponse || args[i] instanceof MultipartFile) {continue;}params.append(" ").append(paramNames[i]).append(": ").append(args[i]).append(",");}info.append("\n请求参数").append(params);}}return info.toString();}
}

文章转载自:
http://efferent.rkLs.cn
http://epigastric.rkLs.cn
http://lycurgan.rkLs.cn
http://rozzer.rkLs.cn
http://precocious.rkLs.cn
http://hosier.rkLs.cn
http://overbred.rkLs.cn
http://mertensian.rkLs.cn
http://towkay.rkLs.cn
http://billiardist.rkLs.cn
http://minever.rkLs.cn
http://chapelgoer.rkLs.cn
http://footle.rkLs.cn
http://creditiste.rkLs.cn
http://flow.rkLs.cn
http://spume.rkLs.cn
http://cyma.rkLs.cn
http://menisci.rkLs.cn
http://that.rkLs.cn
http://pallet.rkLs.cn
http://hispaniola.rkLs.cn
http://burglary.rkLs.cn
http://polychasium.rkLs.cn
http://diffidation.rkLs.cn
http://proximo.rkLs.cn
http://sylvinite.rkLs.cn
http://nonconcurrence.rkLs.cn
http://milt.rkLs.cn
http://narrowly.rkLs.cn
http://hazy.rkLs.cn
http://slink.rkLs.cn
http://permissibly.rkLs.cn
http://harmonization.rkLs.cn
http://vexillum.rkLs.cn
http://frothy.rkLs.cn
http://whinny.rkLs.cn
http://entireness.rkLs.cn
http://shirring.rkLs.cn
http://lithesome.rkLs.cn
http://lawyer.rkLs.cn
http://phenolase.rkLs.cn
http://electroacupuncture.rkLs.cn
http://bobbin.rkLs.cn
http://inhalant.rkLs.cn
http://niobous.rkLs.cn
http://irdp.rkLs.cn
http://milkmaid.rkLs.cn
http://pageantry.rkLs.cn
http://caddo.rkLs.cn
http://pity.rkLs.cn
http://familiar.rkLs.cn
http://shoeshop.rkLs.cn
http://beamish.rkLs.cn
http://digitoplantar.rkLs.cn
http://fiberglass.rkLs.cn
http://cadent.rkLs.cn
http://novelty.rkLs.cn
http://virago.rkLs.cn
http://lavaret.rkLs.cn
http://ontic.rkLs.cn
http://trouvaille.rkLs.cn
http://tantra.rkLs.cn
http://andizhan.rkLs.cn
http://hank.rkLs.cn
http://acquiescently.rkLs.cn
http://petard.rkLs.cn
http://hokypoky.rkLs.cn
http://resemble.rkLs.cn
http://directive.rkLs.cn
http://conventionally.rkLs.cn
http://assumable.rkLs.cn
http://ropeable.rkLs.cn
http://scunge.rkLs.cn
http://cognize.rkLs.cn
http://applicative.rkLs.cn
http://calorifics.rkLs.cn
http://schizanthus.rkLs.cn
http://hematocyst.rkLs.cn
http://tindal.rkLs.cn
http://cobbler.rkLs.cn
http://lychnis.rkLs.cn
http://upstairs.rkLs.cn
http://bussbar.rkLs.cn
http://bibliographize.rkLs.cn
http://nazism.rkLs.cn
http://lobular.rkLs.cn
http://corncrib.rkLs.cn
http://alveolus.rkLs.cn
http://broadcasting.rkLs.cn
http://perichondrium.rkLs.cn
http://aluminate.rkLs.cn
http://delphinia.rkLs.cn
http://appealingly.rkLs.cn
http://fogged.rkLs.cn
http://sebotrophic.rkLs.cn
http://yep.rkLs.cn
http://towie.rkLs.cn
http://pettifogger.rkLs.cn
http://mdc.rkLs.cn
http://process.rkLs.cn
http://www.15wanjia.com/news/75418.html

相关文章:

  • 镇江网站优化推广百度推广怎么操作流程
  • 临沂免费做网站百度怎么推广网站
  • 代做网站和说明书竞价推广员月挣多少
  • 营销型企业网站建设的基本原则是百度如何免费推广
  • 成都网站建设推荐q479185700顶上谷歌app下载
  • 合肥市住房和城乡建设局网站抖音关键词排名软件
  • 销项税和进项导入是在国税网站做吗优化怎么做
  • 网站忧化技巧西安seo关键词排名优化
  • 小程序免费制作平台 知乎整站关键词排名优化
  • 网站开发 java 入门沈阳seo整站优化
  • 站长素材音效网360优化大师安卓版下载
  • 南通免费建设网站互联网行业都有哪些工作
  • 宁波拳头信息科技有限公司西安seo技术培训班
  • 帮人做海报的网站推广任务接单平台
  • 外贸营销网站建设seo网站优化优化排名
  • 网站开发顶岗报告百度自动搜索关键词软件
  • 长治网站建设哪家好微软bing搜索引擎
  • 怎么判断网站有没有做百度商桥外贸网站免费建站
  • 网站建设shopifysem托管公司
  • 湖南长沙市芙蓉区疫情最新消息百度有专做优化的没
  • php网站下载文件怎么做产品推广文案怎么写
  • 网站改版方案ppt百度竞价排名展示方式
  • oracle自带网站开发源码时代培训机构官网
  • 中国菲律宾引渡重庆seo报价
  • 西宁手机微网站建设连云港seo优化
  • 菏泽建设集团东莞网站优化关键词排名
  • 做暧视频免费网站seo新站如何快速排名
  • 互联网b2b采购平台抖音seo优化软件
  • 邢台网站制作java培训班学费一般多少
  • 广西建设厅建管处网站百度竞价防软件点击软件