Twitter bootstrap GET/bootstrap/js/bootstrap.min.js没有映射
我已经在我的spring boot项目中为图像配置了一个文件夹,之后我的项目不会映射我的boostrap样式Twitter bootstrap GET/bootstrap/js/bootstrap.min.js没有映射,twitter-bootstrap,spring-boot,Twitter Bootstrap,Spring Boot,我已经在我的spring boot项目中为图像配置了一个文件夹,之后我的项目不会映射我的boostrap样式 @Configuration @EnableWebMvc public class WebConfig implements WebMvcConfigurer{ @Value("${demo.ruta.imagenes}") private String rutaImagenes; public void addResourceHandlers(Resourc
@Configuration
@EnableWebMvc
public class WebConfig implements WebMvcConfigurer{
@Value("${demo.ruta.imagenes}")
private String rutaImagenes;
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/logos/**").addResourceLocations("file:" + rutaImagenes);
}
}
我的文件夹资源:
在我的html文件中,我得到了我的样式:
在标题中:
<link th:href="@{/bootstrap/css/bootstrap.min.css}" rel="stylesheet">
<!-- Custom styles for this template -->
<link th:href="@{/bootstrap/css/jumbotron.css}" rel="stylesheet">
<link th:href="@{/bootstrap/css/sticky-footer-navbar.css}" rel="stylesheet">
<link href="https:/ /use.fontawesome.com/releases/v5.5.0/css/all.css" rel="stylesheet">
在全体会议之前:
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script th:src="@{/bootstrap/js/bootstrap.min.js}"></script>
我已经实现了这个方法和引导get映射
@Configuration
public class WebConfig implements WebMvcConfigurer {
private static final String[] CLASSPATH_RESOURCE_LOCATIONS = {
"classpath:/META-INF/resources/", "classpath:/resources/",
"classpath:/static/", "classpath:/public/" };
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/**")
.addResourceLocations(CLASSPATH_RESOURCE_LOCATIONS);
}
}
我在将引导添加到项目中时遇到了相同的问题,因为我正在使用
spring security
configuration安全策略阻止引导资源,并且我已在websecurityconfigureadapter
扩展类,如下面的代码
public class DemoSecurityConfig extends WebSecurityConfigurerAdapter{
@Override
public void configure(WebSecurity web) throws Exception {
// Web resource
web.ignoring().antMatchers("/resources/css/**");
web.ignoring().antMatchers("/resources/fonts/**");
web.ignoring().antMatchers("/resources/js/**");
}
}
如果您想要更多,我将从此站点执行此步骤
这就解决了我的问题,我希望你也一样