gpt4 book ai didi

configuration - 使用Spring Boot和Thymeleaf加载静态资源

转载 作者:行者123 更新时间:2023-12-04 13:49:41 25 4
gpt4 key购买 nike

我想加载我的静态资源。首先,我认为它已经可以工作了,但这只是浏览器缓存的一个窍门。我只按预期加载了html文件,但未获取js,css,图像等。

======

我的入门类:

@Configuration
@Import({ ServiceConfig.class, WebMvcConfig.class })
@EnableHypermediaSupport(type = HAL)
@EnableAutoConfiguration
public class ApplicationClientMvc {
public static void main(final String[] args) {
SpringApplication.run(ApplicationClientMvc.class, args);
}
}

======

WebMvcConfig
@Configuration
@ComponentScan
public class WebMvcConfig extends WebMvcConfigurationSupport {

@Autowired public SpringTemplateEngine templateEngine;

@Bean
public ThymeleafTilesConfigurer tilesConfigurer() {
final ThymeleafTilesConfigurer configurer = new ThymeleafTilesConfigurer();
configurer.setDefinitions("classpath*:/templates/**/views.xml");
return configurer;
}

@Bean
public ThymeleafViewResolver thymeleafViewResolver() {
final ThymeleafViewResolver resolver = new ThymeleafViewResolver();
resolver.setViewClass(ThymeleafTilesView.class);
resolver.setTemplateEngine(templateEngine);
resolver.setCharacterEncoding(UTF_8);
return resolver;
}

@Bean
public TilesDialect tilesDialect() {
return new TilesDialect();
}

//

@Value("${server.session-timeout}") private Long sessionTimeOut;

@Override
public void configureAsyncSupport(final AsyncSupportConfigurer configurer) {
configurer.setDefaultTimeout(sessionTimeOut * 1000L);
configurer.registerCallableInterceptors(timeoutInterceptor());
}

@Bean
public TimeoutCallableProcessingInterceptor timeoutInterceptor() {
return new TimeoutCallableProcessingInterceptor();
}
}

======

我的项目资源

=====

访问资源

尝试获取资源的样式不同,它们都不起作用!!!

最佳答案

您在路径中不需要static。尝试/css/bbs-login.css

关于configuration - 使用Spring Boot和Thymeleaf加载静态资源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27869267/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com