【问题标题】:Resource mapping not working in spring 5 with no xml configuration资源映射在没有 xml 配置的 spring 5 中不起作用
【发布时间】:2018-10-16 10:04:05
【问题描述】:

没有为以下配置加载资源。请帮助。我正在使用没有 xml 配置的 Spring 5 以下是我在配置页面上的资源处理函数

@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">

这是我的资源文件夹所在的位置 resource location image

【问题讨论】:

    标签: java html css spring spring-mvc


    【解决方案1】:

    我找到了出路。正如我在上述问题中描述的那样,一切都是正确的。问题出在 spring 安全配置中。你必须添加代码来绕过安全性以在 spring 安全配置文件中加载资源public void configure(WebSecurity web) throws Exception { web.ignoring().antMatchers("/resources/**");

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-07-21
      • 2017-01-30
      • 2016-04-19
      • 1970-01-01
      • 1970-01-01
      • 2013-11-26
      • 1970-01-01
      • 2015-02-26
      相关资源
      最近更新 更多