【问题标题】:getting error cannot be found on object of type 'org.springframework.webflow.engine.impl.RequestControlContextImpl'在“org.springframework.webflow.engine.impl.RequestControlContextImpl”类型的对象上找不到错误
【发布时间】:2013-06-10 11:14:47
【问题描述】:

我是 Spring Web Flow 的新手。我正在练习spring web flow和JSF。当我运行项目时,出现以下错误

SEVERE: Servlet.service() for servlet [appServlet] in context with path 
[/ch18_SpringWebFlowAndJSF] threw exception [Request processing failed; nested 
exception is org.springframework.webflow.execution.ActionExecutionException: 
Exception thrown executing [AnnotatedAction@6e72e380 targetAction = 
[EvaluateAction@38b62126 expression = contactController.newContactListBean(), 
resultExpression = viewScope.contactListBean], attributes = map[[empty]]] in state 
'start' of flow 'contacts' -- action execution attributes were 'map[[empty]]'] with 
root cause

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

这是我的控制器

@Component("contactController")
public class ContactController {

    private static final Logger logger = LoggerFactory.getLogger(ContactController.class);

    @Autowired
    private ContactService contactService;

    @Autowired
    private HobbyService hobbyService;

    public ContactListBean newContactListBean() {

        ContactListBean contactListBean = new ContactListBean();
        contactListBean.setContacts(contactService.findAll());
        return contactListBean; 
    }

} //end of class ContactController

这是我的 flow.xml

<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"
start-state="start" >

<view-state id="start" view="list.xhtml">
    <on-entry>
        <evaluate expression="contactController.newContactListBean()" result="viewScope.contactListBean"/>
    </on-entry>

    <transition on="view" to="show">
        <set name="requestScope.contactId" value="contactListBean.selectedContact.id"/>
    </transition>

    <transition on="add" to="add-step-1">
        <evaluate expression="contactController.newContactBean()" result="flowScope.contactBean"/>
    </transition>
</view-state>

...

<global-transitions>
    <transition on="exit" to="start"/>
</global-transitions>


</flow>

当我调试我的代码时,它涉及到newContactListBean() method。但在那之后它给出了错误。

我做错了什么?

谢谢

【问题讨论】:

    标签: jsf-2 spring-webflow-2


    【解决方案1】:

    请务必使用

    <context:annotation-config />
    <context:component-scan base-package="your base package" />
    

    在您的 applicationContext.xml 文件中

    【讨论】:

    • 非常感谢您的回答我在 applicationContext.xml 文件中缺少相同的内容,尽管我使用基于 java 的配置,但我使用基于 xml 的配置来加载与 webflow 相关的 bean。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-12-10
    • 1970-01-01
    • 2013-11-24
    • 1970-01-01
    • 1970-01-01
    • 2013-05-31
    • 1970-01-01
    相关资源
    最近更新 更多