【发布时间】:2016-02-01 21:18:35
【问题描述】:
我刚开始将 Webflow 添加到 Spring MVC 项目中,但我的 flow.xml 组件上出现了这个编译错误:
Start state is missing. Add at least one state to the flow
我在一年前在 SO 上发现了一个相同的帖子:webflow.xsd - Start state is missing. Add at least one state to the flow。 没有人回答这个问题,但我在 Spring Webflow 的 Jira 存储库中找到了它:webflow.xsd - Start state is missing. Add at least one state to the flow。它被标记为无法复制。
这是我非常简单的 webflow.xml 的摘录。
<?xml version="1.0" encoding="UTF-8"?>
<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.4.xsd">
<on-start>
<evaluate expression="recipeService.createRecipe(currentUser.name)" result="flowScope.recipe" />
</on-start>
<view-state id="basics" view="recipe/basics" model="recipe">
<transition on="proceed" to="ingredients"></transition>
<transition on="cancel" to="cancel"></transition>
</view-state>
... more states ...
<end-state id="end" view="recipe/end"/>
<end-state id="cancel" view="recipe/end"/>
</flow>
文档表明 start-state 是可选的 - 第一个 view-state 将被假定为开始。如果我将 spring-webflow-2.4.xsd 更改为 2.0,错误就会消失,但是如果我尝试在任何视图状态条目上使用验证提示,则会出现不同的错误。下面示例中的“Basic1”和“Basic2”是配方模型上的验证组。
<view-state id="basics" view="recipe/basics" model="recipe" validation-hints="'basic1,basic2'">
我正在使用
- STS 3.6.4
- Spring 4.1.6.RELEASE
- Spring WebFlow 2.4.2.RELEASE
- Spring Security 4.0.2.RELEASE
- Java 1.7
- 休眠 4.3.10.FINAL
我对所有内容都使用基于 java 的配置,但我认为这不是问题所在,除非 Webflow 2.4.2 所需的版本不匹配?如果有帮助,我可以发布我的 WebMvcConfig 和 WebFlowConfig 或 pom.xml 或任何其他信息。
任何帮助将不胜感激。
编辑 #1:java 配置摘录
From WebFlowConfig.java:
@Bean
public FlowDefinitionRegistry flowRegistry() {
return getFlowDefinitionRegistryBuilder(flowBuilderServices())
.setBasePath("/WEB-INF/views")
.addFlowLocationPattern("/**/*-flow.xml")
.build();
}
From WebMvcConfig.java
@Override
public void addViewControllers(final ViewControllerRegistry registry) {
super.addViewControllers(registry);
registry.addViewController("/recipe/basics.htm");
registry.addViewController("/recipe/ingredients.htm");
registry.addViewController("/recipe/instructions.htm");
registry.addViewController("/recipe/optional.htm");
registry.addViewController("/recipe/end.htm");
}
使用 2.0,所有页面都以正确的顺序执行。
编辑#2
我忘了提到,即使出现 2.4 xsd 编译错误,webflow 也会执行,与一年前的帖子相同。我还发现了关于 STS 的这个问题:webflow config gives incorrect "Start state definition is missing." error。指示的修复版本是 3.3.0.M1,所以我假设(?)修复仍然包含在 STS 3.6.4 中。
【问题讨论】:
标签: spring spring-mvc spring-webflow spring-webflow-2