簡體   English   中英

Spring Web Flow和Spring MVC URL 404

[英]Spring Web Flow and Spring MVC URL 404

我目前正在使用Spring MVC 4.0.5,並且想對某些面向過程的頁面使用Spring Web Flow。 但是,我認為我的配置仍然存在一些問題。

在服務器日志中:

2014-09-15 20:54:49,280 [localhost-startStop-1] DEBUG org.springframework.webflow.definition.registry.FlowDefinitionRegistryImpl  - Registering flow definition 'ServletContext resource [/WEB-INF/flows/registration/registration-flow.xml]' under id 'registration'

但是,訪問它時,日志顯示

2014-09-15 20:54:49,820 [http-bio-8080-exec-2] DEBUG org.springframework.webflow.mvc.servlet.FlowHandlerMapping  - No flow mapping found for request with URI '/appContext/registration/'

這是我的網絡流程配置

@Configuration
public class WebFlowConfig extends AbstractFlowConfiguration {

private Logger logger = Logger.getLogger(WebFlowConfig.class);

@Bean
@Autowired
public FlowExecutor flowExecutor(FlowDefinitionRegistry flowRegistry,
        PlatformTransactionManager txManager, SessionFactory sessionFactory) {
    return getFlowExecutorBuilder(flowRegistry)
            .addFlowExecutionListener(new SecurityFlowExecutionListener(),
                    "*")
            .addFlowExecutionListener(
                    new HibernateFlowExecutionListener(sessionFactory,
                            txManager), "*").build();
}

@Bean
@Autowired
public FlowDefinitionRegistry flowRegistry(
        FlowBuilderServices flowBuilderServices) {
    return getFlowDefinitionRegistryBuilder(flowBuilderServices)
            .setBasePath("/WEB-INF/flows")
            .addFlowLocationPattern("/**/*-flow.xml").build();
}

@Bean
@Autowired
public FlowBuilderServices flowBuilderServices(
        MvcViewFactoryCreator mvcViewFactoryCreator, Validator validator) {
    return getFlowBuilderServicesBuilder()
            .setViewFactoryCreator(mvcViewFactoryCreator)
            .setValidator(validator).setDevelopmentMode(true).build();
}

@Bean
@Autowired
public MvcViewFactoryCreator mvcViewFactoryCreator(
        InternalResourceViewResolver viewResolver) {
    MvcViewFactoryCreator factoryCreator = new MvcViewFactoryCreator();
    factoryCreator.setViewResolvers(Arrays.asList(viewResolver));
    return factoryCreator;
}

@Bean
@Autowired
public FlowHandlerMapping flowHandlerMapping(FlowDefinitionRegistry registry) {
    FlowHandlerMapping handlerMapping = new FlowHandlerMapping();
    handlerMapping.setOrder(-1);
    handlerMapping.setFlowRegistry(registry);
    return handlerMapping;
}

@Bean
@Autowired
public FlowHandlerAdapter flowHandlerAdapter(FlowExecutor executor) {
    FlowHandlerAdapter handlerAdapter = new FlowHandlerAdapter();
    handlerAdapter.setFlowExecutor(executor);
    handlerAdapter.setSaveOutputToFlashScopeOnRedirect(true);
    return handlerAdapter;
}
}

希望有人能幫忙。 謝謝。

您正在webflow配置中指定FlowHandlerMapping

    Implementation of HandlerMapping that follows a simple convention 
    for creating URL path mappings from the ids of registered flow definitions. This 
    implementation returns a FlowHandler that invokes a flow if the current request 
    path matches the id of a flow in the configured FlowDefinitionRegistry.

Spring Web Flow的默認FlowUrlHandler實現是DefaultFlowUrlHandler

    Expects URLs to launch flow to be of this pattern:

    http://<host>/[app context path]/[app servlet path]/<flow path>

    The flow id is treated as the path info component of the request URL string. 
    If the path info is null, the servletPath will be used as the flow id. Also, if 
    the servlet path ends in an extension it will be stripped when calculating the flow id.
    The flow definition URL for the given flow id will be built by appending the 
    flow id to the base app context and servlet paths.

您的路徑信息必須為空,並且servlet映射類似於:/ appContext / registration / *,導致流ID為/ appContext / registration /,但未注冊。 因此,請檢查您的servlet映射。

刪除MvcViewFactoryCreator定義和.setViewFactoryCreator(mvcViewFactoryCreator)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM