404 用于春季启动时的静态图像

Can*_*dın 5 spring-boot

在该html文件中,有一个图像:

        <div class="login-branding">
        <a href="index.html"><img src="../static/images/logo.png" alt="Clevex" title="Clevex"></a>
    </div>
Run Code Online (Sandbox Code Playgroud)

在http://localhost:8090/login地址,我查看控制台并看到:

获取http://localhost:8090/static/images/logo.png 404

但是当申请完成时,如果我去

http://localhost:8090/images/logo.png

这个网址,我可以在浏览器控制台看到图像,没有任何错误或警告chrome

这是我的安全配置:

@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {

    @Autowired
    private CustomAuthenticationProvider customAuthenticationProvider;

    @Override
    protected void configure(HttpSecurity http) throws Exception {

 http.cors().and().csrf().disable();

        String[] resources = new String[]{
                "/",
                "/home",
                "/pictureCheckCode",
                "/include/**",
                "/css/**",
                "/icons/**",
                "/images/**",
                "/js/**",
                "/resources/**",
                "/layer/**",
                "/static/**",
                "/js/**",
                "/img/**",
                "/webjars/**"
        };

   http
                .authorizeRequests()

                .antMatchers(resources).permitAll()
Run Code Online (Sandbox Code Playgroud)

我也添加了@EnableAutoConfiguration,但它没有做任何事情。并且也给出了错误。

我不想使用addResourceHandlers因为它是 spring boot 并且它应该进行自动配置。

目录是这样的:

src
-main
-resources
--static
---images
----logo.png
Run Code Online (Sandbox Code Playgroud)

这是应用程序的启动方式:

@SpringBootApplication
public class InternalApplication {

    public static void main(String[] args) {
        SpringApplication.run(InternalApplication.class, args);
    }

}
Run Code Online (Sandbox Code Playgroud)

任何建议将被认真考虑。

Can*_*dın 2

这有效:

/sf/answers/3933734521/

我变了

<a href="index.html"><img src="../static/images/logo.png" alt="Clevex" title="Clevex"></a>
Run Code Online (Sandbox Code Playgroud)

            <a href="index.html"><img src="/images/logo.png" alt="Clevex" title="Clevex"></a>
Run Code Online (Sandbox Code Playgroud)

我很困惑,因为Intellij Idea

HTML代码中,如果我点击../static/images/logo.png,它可以转到图像。

但是当我单击/images/logo.pngHTML 代码时,它不会执行,还会sonar发出警告。