Как я могу разрешить статические ресурсы в SpringWebFlow + SpringBoot? - PullRequest
1 голос
/ 21 мая 2019

У меня есть эта структура проекта
-> src / main / java

-> src / main / resources / static / myFolder / css / common.css

iиметь этот класс конфигурации

@Configuration
public class WebFlowConfig extends AbstractFlowConfiguration {

@Autowired
private LocalValidatorFactoryBean localValidatorFacotryBean;

@Bean
public FlowDefinitionRegistry flowRegistry() {
    return getFlowDefinitionRegistryBuilder()
            .setBasePath("classpath:flow")
            .addFlowLocationPattern("/myflows/myflow1.xml")
            .addFlowLocationPattern("/myflows/myflow2.xml")
            .setFlowBuilderServices(this.flowBuilderServices())
            .build();
}
@Bean
public FlowExecutor flowExecutor() {
    return getFlowExecutorBuilder(this.flowRegistry()) //
            .build();
}
@Bean
public FlowBuilderServices flowBuilderServices() {
    return getFlowBuilderServicesBuilder() //
            .setViewFactoryCreator(this.mvcViewFactoryCreator()) // Important!
            .setValidator(this.localValidatorFacotryBean).build();
}
// ----------------------------------------------------------
@Bean
public FlowHandlerMapping flowHandlerMapping() {
    FlowHandlerMapping handlerMapping = new FlowHandlerMapping();
    handlerMapping.setOrder(-1);
    handlerMapping.setFlowRegistry(this.flowRegistry());
    return handlerMapping;
}

@Bean
public FlowHandlerAdapter flowHandlerAdapter() {
    FlowHandlerAdapter handlerAdapter = new FlowHandlerAdapter();
    handlerAdapter.setFlowExecutor(this.flowExecutor());
    handlerAdapter.setSaveOutputToFlashScopeOnRedirect(true);
    return handlerAdapter;
}

@Bean
public ViewFactoryCreator mvcViewFactoryCreator() {
    MvcViewFactoryCreator factoryCreator = new MvcViewFactoryCreator();
    factoryCreator.setViewResolvers(Collections.<ViewResolver>singletonList(this.thymeleafViewResolver()));
    factoryCreator.setUseSpringBeanBinding(true);
    return factoryCreator;
}

@Bean
@Description("Thymeleaf AJAX view resolver for Spring WebFlow")
public AjaxThymeleafViewResolver thymeleafViewResolver() {
    AjaxThymeleafViewResolver viewResolver = new AjaxThymeleafViewResolver();
    viewResolver.setViewClass(FlowAjaxThymeleafView.class);
    viewResolver.setTemplateEngine(this.templateEngine());
    viewResolver.setCharacterEncoding("UTF-8");
    return viewResolver;
}

@Bean
@Description("Thymeleaf template resolver serving HTML 5")
public ClassLoaderTemplateResolver templateResolver() {
    ClassLoaderTemplateResolver templateResolver = new     ClassLoaderTemplateResolver();
    templateResolver.setPrefix("templates/");
    templateResolver.setCacheable(false);
    templateResolver.setSuffix(".html");
    templateResolver.setTemplateMode("HTML5");
    templateResolver.setCharacterEncoding("UTF-8");
    return templateResolver;
}

@Bean
@Description("Thymeleaf template engine with Spring integration")
public SpringTemplateEngine templateEngine() {
    SpringTemplateEngine templateEngine = new SpringTemplateEngine();
    templateEngine.setTemplateResolver(this.templateResolver());
    return templateEngine;
}

Я всегда получаю эту ошибку Не найдено сопоставление для HTTP-запроса с URI [/static/common.css] в DispatcherServlet с именем dispatcherServlet

Я всегда получаюэта ошибка кажется, что теги, такие как <link rel = "stylesheet" href = "/ static / myFolder / common.css" /> решаются как HTML

...