java - webflow2 找不到我的 java 代码( Controller )

标签 java spring spring-webflow

我正在尝试运行一个 webflow 项目,但我不断收到以下错误,它无法找到我的 Controller ?

这是我的流程代码:

<flow xmlns="http://www.springframework.org/schema/webflow"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/webflow
                          http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd">

    <var name="member" class="org.uftwf.enrollment.domain.Member" />

    <decision-state id="checkIsInPending">
        <if test="FlowActions.isInPending()" then="endStateMemeberPending" else="name" />
    </decision-state>

    <view-state id="name" view="enrollment1.jsp">
        <transition on="submit" to="SSNonFile" />
        <transition on="cancel" to="endState" bind="false" />
    </view-state>

    <action-state id="SSNOnFile">
     <evaluate expression="FlowActions.isSSNOnFile(member)" />
         <transition on="SUCCESS" to="endStateNoSSN" />
        <transition on="FAIL" to="isMemeber" />
    </action-state>

    <action-state id="isMemeber">
     <evaluate expression="FlowActions.isMemeber(member)" />
         <transition on="SUCCESS" to="endStateMemeberExists" />
        <transition on="FAIL" to="isDeceased" />
    </action-state>

    <action-state id="isDeceased">
     <evaluate expression="FlowActions.isDeceased(member)" />
         <transition on="SUCCESS" to="endStateMemeberExists" />
        <transition on="FAIL" to="address" />
    </action-state>

    <view-state id="address" view="enrollment2.jsp">
        <transition on="submit" to="endStateSuccess" />
        <transition on="cancel" to="name" bind="false" />
    </view-state>


    <view-state id="preview" model="customer">
        <transition on="cancel" to="name" />
        <transition on="accept" to="endStateSuccess">
            <evaluate expression="FlowActions.addCustomer(member)" />
        </transition>
    </view-state>

    <!-- End state -->
    <end-state id="endStateMemberDeceased" view="unsuccessful.jsp" />
    <end-state id="endStateNoSSN" view="noSSN.jsp" />
    <end-state id="endStateMemeberExists" view="exists.jsp" />
    <end-state id="endStateMemeberPending" view="pending.jsp" />
    <end-state id="endStateSuccess" view="success.jsp" />



</flow>

这是我的 Controller 代码:

package org.uftwf.enrollment.controller.swf;
import static org.apache.log4j.Logger.getLogger;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.uftwf.enrollment.domain.Member;
import org.uftwf.enrollment.service.TestService;

@Component
public class FlowActions {

    @Autowired
    private TestService testService;

    private static final Logger LOGGER = getLogger(FlowActions.class);

    public void addCustomer(Member customer) {
    //  testService.saveCustomer(customer);
    }

    public boolean isInPending()
    {
        LOGGER.debug("in side isInPending()");
        return false;
    }

    public void isSSNOnFile(Member customer)
    {

    }

    public void isMemeber(Member customer)
    {

    }

    public void isDeceased(Member customer)
    {

    }





}

疯狂的错误。我的项目无法找到带有 webflow 的 Controller ..

SEVERE: Servlet.service() for servlet [spring] in context with path [/enrollment] threw exception [Request processing failed; nested exception is org.springframework.webflow.execution.FlowExecutionException: Exception thrown in state 'checkIsInPending' of flow 'enroll'] with root cause
org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 0): Field or property 'FlowActions' cannot be found on object of type 'org.springframework.webflow.engine.impl.RequestControlContextImpl'

这是我的 root-config.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">

    <import resource="mvc.xml" />
    <import resource="flow.xml" />
    <import resource="domain.xml" />


    <context:component-scan base-package="org.uftwf.enrollment.controller" />



</beans>

最佳答案

您应该引用 bean flowActions ,不是类 FlowActions 。尝试更改首字母“f”的大小写。

例如

<if test="flowActions.isInPending()" then="endStateMemeberPending" else="name" />

关于java - webflow2 找不到我的 java 代码( Controller ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11976842/

相关文章:

java - 将每个列标题的大小调整为最大内容大小 - NatTable

java - Spring security antMatcher 不起作用

grails webflow - 将非序列化模型传递给 View

java - Spring Webflow,ID 和版本被剥离

java - 忽略子线程生成的日志

java - Spring boot中的jar打包

java - 在运行时更新 bean 属性

ajax - Grails Webflow中的Json响应

Java FileReader 编码问题

java - 如何使用 spring 管理 REST API 版本控制?