Spring promoting request scoped bean to child threads (HttpServletRequest)

前端 未结 2 946
不知归路
不知归路 2021-02-20 01:54

I tried a lot of things now but i seem to miss a piece of the puzzle. Here is the story: I have a request scoped bean that reads some SessionContext from the HttpServletRequest.

2条回答
  •  春和景丽
    2021-02-20 02:34

    In my case using OrderedRequestContextFilter resolve the issue. You have to also set threadContextInheritable flag to true like this :

    @Bean
    public RequestContextFilter requestContextFilter() {
        OrderedRequestContextFilter filter = new OrderedRequestContextFilter();
        filter.setThreadContextInheritable(true);
        return filter;
    }
    

提交回复
热议问题