[英]Resource mapping not working in spring 5 with no xml configuration
沒有為以下配置加載資源。請提供幫助。我使用的是Spring 5,沒有xml配置以下是我在配置頁面上的資源處理函數
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/resources/**").addResourceLocations("/resources/");
}
這就是我在jsp頁面中引用資源的方式
<link rel="stylesheet" type="text/css" href="resources/vendor/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="resources/css/util.css">
<link rel="stylesheet" type="text/css" href="resources/css/main.css">
這是我的資源文件夾所在的位置資源位置圖像
我找到了出路,如我在上述問題中所述,一切都正確。 問題出在spring安全配置中public void configure(WebSecurity web) throws Exception { web.ignoring().antMatchers("/resources/**");
必須添加代碼以繞過安全性以在spring安全配置文件中加載資源public void configure(WebSecurity web) throws Exception { web.ignoring().antMatchers("/resources/**");
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.