webflux接收application/x-www-form-urlencoded参数

张开发
2026/6/7 20:15:05 15 分钟阅读
webflux接收application/x-www-form-urlencoded参数
记录开发中遇到的问题请求方式需要用如下方式接收方式1PostMapping(value/user/logout,consumesapplication/x-www-form-urlencoded)publicResponseResultlogoutForAuthSystem(ServerWebExchangeexchange){exchange.getFormData().subscribe(formData-{StringsubformData.getFirst(sub);StringnameformData.getFirst(name);log.info([第三方认证系统] 登出用户ID {}, 账号 {},sub,name);tokenService.deleteUserCache(name);});returnResponseResult.ok(登出成功);}方式2PostMapping(/user/logout)publicvoidrefreshSysConfig(ServerHttpRequestrequest){// 直接解析 form 表单request.getBody().subscribe(buffer-{StringbodyStrbuffer.toString(StandardCharsets.UTF_8);StringnamebodyStr.replace(name,).trim();System.out.println(成功拿到name);});}

更多文章