Invalid mapping pattern detected: /**/*.css ^ No more pattern data allowed after {*...} or ** pattern element


報錯:

***************************
APPLICATION FAILED TO START
***************************

Description:

Invalid mapping pattern detected: /**/*.css
^
No more pattern data allowed after {*...} or ** pattern element

Action:

Fix this pattern in your application or switch to the legacy parser implementation with `spring.mvc.pathpattern.matching-strategy=ant_path_matcher`.


Process finished with exit code 0

 

定位:

    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(alphaInterceptor) //攔截一切請求
           .excludePathPatterns("/**/*.css","/**/*.js","/**/*.png","/**/*.jpg","/**/*.jpeg") //排除訪問靜態資源,所有目錄下的cs文件
            .addPathPatterns("/register","/login");

原因:

路徑通配問題,查找發現是spring升級到5.3之后路徑通配發生了變化,官方給出的解釋是“In Spring MVC, the path was previously analyzed by AntPathMatcher, but it was changed to use PathPatternParser introduced in WebFlux from Spring 5.3.0.”通配符發生了變化。把/**/*.css 改為 /*/*.css即可。

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(alphaInterceptor) //攔截一切請求
                .excludePathPatterns("/*/*.css","/*/*.js","/*/*.png","/*/*.jpg","/*/*.jpeg") //排除訪問靜態資源,所有目錄下的cs文件
                .addPathPatterns("/register","/login");
    }

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM