【问题标题】:Spring webflow - access to sessionSpring webflow - 访问会话
【发布时间】:2013-11-25 20:47:02
【问题描述】:

我正在尝试在 spring webflow 中获取 session 属性,但它不起作用。在某些控制器中,我有:

User u = userDao.getUser(userName);
session.setAttribute("sessionUser", u);

在 JSP 中,我可以得到它,它工作正常:

${sessionScope.sessionUser.getLogin()}

我尝试过这样的事情:

<decision-state id="isUserLogged">
    <if test="sessionUser.getLogin() != null" then="startView" else="start" />
</decision-state>

但我得到了错误:

EL1008E:(pos 0): Field or property 'sessionUser' cannot be found on object of type 'org.springframework.webflow.engine.impl.RequestControlContextImpl'

<decision-state id="isUserLogged">
        <if test="${sessionScope.sessionUser.getLogin()}" then="startView" else="start" />
    </decision-state>

错误:

 EL1041E:(pos 1): After parsing a valid expression, there is still more data in the expression: 'lcurly({)'

我的第一个问题是,如何在 webflow 中获取sessionUser

我也尝试调用控制器方法,因为在控制器方法中我可以得到sessionUser,但它不起作用。

我的第二个问题是,如何在 webflow 中调用控制器方法?

【问题讨论】:

    标签: spring session spring-mvc spring-webflow


    【解决方案1】:

    Spring Web Flow 中没有 sessionScope。要访问 Session 上的对象,您需要使用 externalContext 隐式 el 变量,如下所示:

    <if test="externalContext.sessionMap.sessionUser.getLogin() != null" then="startView" else="start" />
    

    【讨论】:

      猜你喜欢
      • 2015-07-06
      • 1970-01-01
      • 1970-01-01
      • 2011-10-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-21
      相关资源
      最近更新 更多