gpt4 book ai didi

java - 资源映射在没有 xml 配置的 spring 5 中不起作用

转载 作者:太空宇宙 更新时间:2023-11-04 10:29:23 25 4
gpt4 key购买 nike

以下配置未加载资源。请帮忙。我使用的是 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">

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

最佳答案

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

关于java - 资源映射在没有 xml 配置的 spring 5 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50199968/

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