spring - ServerWebExchange attributes are empty
问题描述
I have Spring Boot annotation based controller built on WebFlux. I implement WebFilter
, inside WebFilter
I invoked serverWebExchange.getAttributes()
and it returned 4 attributes which is fine. But after that it stopped working and now it always returns empty attributes map. I didn't change anything in controller, but even if I did I should still get those attributes. Why it stopped working?
解决方案
它在我第一次做的时候起作用:
this.handlerMapping.getHandler(serverWebExchange)
wherehandlerMapping
是一个RequestMappingHandlerMapping
可以从 WebFlux 注入的 bean。
这行代码初始化serverWebExchange
属性。有问题我写道,它工作过一次,然后就停止了。原因是我当时正在试验handlerMapping
并且它使它工作,然后我删除它并且属性停止被初始化。调试表明,通常这些属性是在WebFilter
应用 s 之后设置的。这行代码使它更早地初始化。
推荐阅读
- tensorflow - (2 或 3)维全连接层如何工作?
- flutter - 构建Flutter.framework时删除icudtl.dat后有什么影响
- javascript - 我如何完美地将东西放在底部横幅中?
- python - 迭代地将两个 3D Pytorch 张量相乘
- python - python环境下安装PROJ的问题
- c++ - C++中空指针的比较
- python - 在 JSON 中映射键和值
- javascript - 如何在 scss 或 css reactjs 中创建条件颜色
- c - 如果在退出之前没有在子进程中释放内存,是否是泄漏?
- reactjs - 在 Azure Linux 上部署 NextJs