有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!


共 (2) 个答案

  1. # 1 楼答案

    Flash Scope From the DOC

    The Flash scope works exactly like the Session, but with two differences: data are kept for only one request the Flash cookie is not signed, making it possible for the user to modify it.

    例如:

    public static Result index() {
      String message = flash("success");
      if(message == null) {
        message = "Welcome!";
      }
      return ok(message);
    }
    
    public static Result save() {
      flash("success", "The item has been created");
      return redirect("/home");
    }
    

    请求范围是直接的,它只针对特定请求存在

  2. # 2 楼答案

    Flash scope旨在解决当我们将一个JSF页面重定向到另一个页面时发生的数据交换问题

    重定向JSF页面时会生成两个请求。第一个请求是发回源JSF页面。第二个请求是对目标JSF页面的初始请求。第一个作用域中的请求作用域中的对象在第二个请求中被清除

    为了克服这个问题,在重定向到另一个JSF页面时,使用Flash scope交换数据

    查看更多: