msemelman
msemelman

Reputation: 2937

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

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 FooRequestAware {
      private final Request req;
      public final bar() {}
}

Upvotes: 1

Views: 442

Answers (1)

skaffman
skaffman

Reputation: 403481

Yes, just autowire it

public class FooRequestAware {
      private @Autowired HttpServletRequest req;

      public final bar() {}
}

Upvotes: 2

Related Questions