zoukankan      html  css  js  c++  java
  • WebFlux中thymeleaf视图找不到的问题解决

    由于在weblux临时增加一个H5的页面,发生如下错误

    Whitelabel Error Page

    This application has no configured error view, so you are seeing this as a fallback.

    Fri Nov 27 11:18:57 CST 2020
    There was an unexpected error (type=Internal Server Error, status=500).
    Could not resolve view with name 'index'.

     最开始以为是视图路径的问题,测试没通过,考虑其它的解决方案,在网上找了一些,其实朋友说需要增加自定义模板配置,遂记录之.

    @Configuration
    @EnableWebFlux
    public class WebAppConfig implements WebFluxConfigurer {
    
        //引入spring-boot-starter-thymeleaf自动会注入该bean
        @Autowired
        private ThymeleafReactiveViewResolver thymeleafReactiveViewResolver;
    
    
        /**
         * 加入thymeleaf试图解析器,不然找不到view name
         *
         * @param registry
         */
        @Override
        public void configureViewResolvers(ViewResolverRegistry registry) {
            registry.viewResolver(thymeleafReactiveViewResolver);
        }
    
    }
    

      

  • 相关阅读:
    洛谷P5281 [ZJOI2019] Minimax搜索
    势函数
    Comet OJ [Contest #5] 迫真大游戏
    洛谷P3307 [SDOI2013] 项链
    洛谷P5985 [PA2019] Muzyka pop
    CF1205E Expected Value Again
    review
    CF891E Lust
    线性代数
    洛谷P4607 [SDOI2018] 反回文串
  • 原文地址:https://www.cnblogs.com/cqwo/p/14047003.html
Copyright © 2011-2022 走看看