我是春季网络流程的新手。我正在练习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
。但在那之后它会给出错误。
我做错了什么?
谢谢
答案 0 :(得分:1)
确保使用
<context:annotation-config />
<context:component-scan base-package="your base package" />
你的applicationContext.xml文件中的