[springMVC]03.20复习springMVC域对象共享数据(涉及到单点登录)

springMVC

SpringMVC域对象共享数据

就是能在一定的范围内共享数据,通常使用三种

  • request:一次请求,多个资源共享数据
  • session:默认一次会话,多个请求,多个资源共享数据
  • servletContext:一个应用,多个会话,多个请求,多个资源共享同一份数据

使用原则

在满足条件的前提下,能选择小范围的就不选则大范围的.eg:查询列表的场景,这种一般放在request域中.
不过底层都是使用了ModelAndView封装的

向request域对象中共享数据

  1. 使用原生的servletAPI向request域对象共享数据
    image

  2. 使用ModelAndView向request域对象中共享数据
    image

Model ModelMap Map的关系

public interface Model();
public class ModelMap extends LinkedHashMap<String , Object>{}
public class ExtendedModelMap extends ModelMap implements Model {}
public class BindingAwareModelMap extends ExtendeModelMap{}

向session域对象中共享数据

image

向application域对象中共享数据

image

posted @ 2022-03-20 20:11  1_f  阅读(20)  评论(0)    收藏  举报