Session is only valid in the current tomcat instance, so in the case of multiple tomcat instances, you cannot use request.getSession().getAttribute to obtain the session, but obtain it from redis.
In the cluster session retention solution, you can store the sessionId as a key in redis (the value is the session information you want to save). Of course, when you retrieve it, you need to retrieve it from redis. Tomcat does not save the session information.
There is a third-party jar package that can be integrated with tomcat to save the session in redis. The application code does not need to pay attention to this matter
Redis puts the object and it is null when it is taken out. It is good to put the string. It seems that the only way is to convert the object to json
Problem solved: The bean object was not serialized, causing an exception in redis, but it was normal after serialization
Session is only valid in the current tomcat instance, so in the case of multiple tomcat instances, you cannot use request.getSession().getAttribute to obtain the session, but obtain it from redis.
Now that redis is used, there is no need to use the session in the container. .
In the cluster session retention solution, you can store the sessionId as a key in redis (the value is the session information you want to save). Of course, when you retrieve it, you need to retrieve it from redis. Tomcat does not save the session information.
There is a third-party jar package that can be integrated with tomcat to save the session in redis. The application code does not need to pay attention to this matter
Try spring-session