【问题标题】:vaadin access session attribute that was put in filter放在过滤器中的 vaadin 访问会话属性
【发布时间】:2015-04-20 22:51:58
【问题描述】:

我有多个过滤器。 在其中一个过滤器中,我有这段代码

HttpServletRequest request = (HttpServletRequest) req;
String url = request.getRequestURI();

HttpSession session = request.getSession();
if (request.getParameter("xxxx") != null)
    session.setAttribute("xxxx", request.getParameter("xxxx"));
chain.doFilter(req, res);

对于 UI,我使用 VAADIN 7。 我决定在表格中显示参数xxxx 的值。 所以我想这样做

Table table = new Table("Data.");
table.setSizeFull();
table.addContainerProperty("Field", String.class, null);
table.addContainerProperty("Value", String.class, null);
table.setStyleName("wordwrap-table");
table.setStyleName("user-table");

Object attribute = VaadinSession.getCurrent().getAttribute("xxxx");

但是attribute 的值是null。 为什么?以及如何解决这个问题?

【问题讨论】:

    标签: httprequest vaadin httpsession


    【解决方案1】:

    你需要另一个getSession()

    Object attribute = VaadinSession.getCurrent().getSession().getAttribute("xxxx");
    

    VaadinSession.getCurrent() 的结果是当前的Vaadin 会话。下一个 getSession() 为您提供 HTTP 会话,这是您的属性所在的位置。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-05-18
      • 2012-11-16
      • 1970-01-01
      • 2013-07-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多