您好,欢迎访问一九零五行业门户网

springboot themaleaf第一次进页面不加载css怎么解决

springboot themaleaf 第一次进页面不加载css近期在做springboot +themaleaf项目中遇到首页css样式不加载情况,后来发现是注册拦截器时没有加入css样式,下边是最开始代码
public void addinterceptors(interceptorregistry registry) { registry.addinterceptor( new loginhandleinterceptor()).addpathpatterns("/**") .excludepathpatterns("/index.html", // 排除掉首页请求 "/", // 排除掉首页请求 ) ; //registry.addinterceptor(new handlerinterceptor()). }
第一次访问登录页面的时候,对应的js css呗拦截器拦截,就没有加载,只需要把对应的css,jquery等放入到拦截器中就可以了
public void addinterceptors(interceptorregistry registry) { registry.addinterceptor( new loginhandleinterceptor()).addpathpatterns("/**") .excludepathpatterns("/index.html", // 排除掉首页请求 "/", // 排除掉首页请求 "/user/login", "/asserts/css/*.css", "/asserts/img/*.svg", "/asserts/js/*.js", "/webjars/bootstrap/4.1.1/css/*.css", "/mancenter/*", "/error", "/asserts/lib/jquery/*","/asserts/lib/*.js") ; //registry.addinterceptor(new handlerinterceptor()). }
springboot themaleaf 各种报错问题1.访问themaleaf页面报错
whitelabel error page
this application has no explicit mapping for /error, so you are seeing this as a fallback.
mon jun 24 11:08:43 cst 2019
there was an unexpected error (type=not found, status=404).
no message available
错误1:
调试时加入了webmvcconfig类
package com.feilong.reptile.config; import org.springframework.stereotype.component;import org.springframework.web.servlet.config.annotation.resourcehandlerregistry;import org.springframework.web.servlet.config.annotation.webmvcconfigurer; /** * 配置静态资源映射 * * @author sunziwen * @version 1.0 * @date 2018-11-16 14:57 **/@componentpublic class webmvcconfig implements webmvcconfigurer { /** * 添加静态资源文件,外部可以直接访问地址 * * @param registry */ @override public void addresourcehandlers(resourcehandlerregistry registry) { registry.addresourcehandler("/static/**").addresourcelocations("classpath:/static/"); }}
删除这个类后还是报错,猜测可能是包路径问题,重新建立个新项目,将旧项目转移后,没有再报错。
以上就是springboot themaleaf第一次进页面不加载css怎么解决的详细内容。
其它类似信息

推荐信息