如何解决子文件夹ClassPathResource中的静态文件
我想返回静态文件:
1)
julia> cats = Dict{Int,Cat}()
Dict{Int64,Cat}()
julia> cats[1] = Lion(12)
Lion(12)
julia> cats
Dict{Int64,Cat} with 1 entry:
1 => Lion(12)
以下是我的配置
resource
|_______static
|________assets
|_________css
|__________bootstrap.min.css
访问 @Bean
fun staticRouter(): RouterFunction<ServerResponse> {
return RouterFunctions.resources("/**",ClassPathResource("static/**/"))
}
时,我得到localhost:8080/assets/css/bootstrap.min.css
我写错了图案吗?
2)
但是,如果我删除404 not found
,它就可以工作了
assets
我添加了资产,因为这是必需的。
解决方法
你可以使用
@Bean
fun staticRouter(): RouterFunction<ServerResponse> {
return RouterFunctions.resources("/{*filepaths}",ClassPathResource("static/**/"))
}
见https://www.baeldung.com/spring-5-mvc-url-matching#1-uri-variable-syntax-foo-using-a-handler-method
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。