【问题标题】:How to debug SpEL evaluation when it doesn't evaluate properly in WebFlow?当在 WebFlow 中无法正确评估时,如何调试 SpEL 评估?
【发布时间】:2018-03-29 14:32:32
【问题描述】:

我正在使用 Spring WebFlow 2.5.0,但我的 SpEL 表达式没有被正确评估。我想我的 WebFlow 配置或 SpEL 一定有问题,但我不确定是哪个。

我的 login-flow.xml 中有以下决策状态:

<decision-state id="submitChallenge">
    <on-entry>
        <evaluate expression="authenticationService.respondToChallenge(externalContext.nativeRequest, authRequest)"  result="flowScope.challengeName" result-type="org.springframework.webflow.execution.Event"/>
    </on-entry>
    <if test="flowScope.challengeName == 'success'" then="loginComplete" else="answerChallenge"/>
</decision-state>

但是,即使我的 respondToChallenge() 方法返回 Event.success(),我也永远不会转换到 loginComplete 状态。测试似乎总是评估为 FALSE。

是我的 SpEL 有误,还是我进行评估/测试的方式有误?如何调试 SpEL 评估以查看发生了什么?

我尝试将调试点放在org.springframework.binding.expression.spel.SpringELExpression 类中,但是当我尝试在执行getValue()/etc 时跟踪逻辑时,我有点迷失了。我所能看到的是它始终评估为假。

【问题讨论】:

    标签: spring spring-webflow spring-el


    【解决方案1】:

    在使用调试器更仔细地单步执行之后,我发现我的 flowScope.challengeNamesuccess 的类型不同。因此 Spring 在表达式评估时返回 false,因为它们属于不同类型。

    【讨论】:

      猜你喜欢
      • 2014-02-05
      • 1970-01-01
      • 2018-09-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多