Example

In this example, we will connect Spring Session to use a Redis session store. While the code to put data into session remains the same, the data would be stored to Redis instead of HTTP Session.

There are three simple steps involved:

  1. Add dependencies for Spring Session.
  2. Configure Filter to replace HttpSession with Spring Session.
  3. Enable filtering for Tomcat by extending AbstractHttpSessionApplicationInitializer.

Get Mastering Spring 5.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.