开发者

Is it possible to obtain the Request Object in a request scoped bean?

开发者 https://www.devze.com 2023-01-04 22:59 出处:网络
I have a bean declared to be scope=\"request\". is there a chance to obtain the request being used in that scope?

I have a bean declared to be scope="request". is there a chance to obtain the request being used in that scope?

<bean class="FooRequestAware" scope="request"/>

class Fo开发者_如何学GooRequestAware {
      private final Request req;
      public final bar() {}
}


Yes, just autowire it

public class FooRequestAware {
      private @Autowired HttpServletRequest req;

      public final bar() {}
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号