Answer the question
In order to leave comments, you need to log in
Why are images from static resources not displayed?
For some reason, the application on Spring Boot + Thymeleaf + Spring Security
does not display images in html. In the browser developer tools, the picture is highlighted in red, and the type of this file is generally shown as json, although this is a regular png
picture I tried different images, it does not help
How can this be fixed?
HTML:
<div class="info-icon">
<img th:src="@{/images/download.png}" alt="download">
</div>
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().antMatchers("/").permitAll();
}
}
Answer the question
In order to leave comments, you need to log in
Stop!
So the image is not displayed. 404 error in console.
@Override
public void configure(WebSecurity web) {
web.ignoring().antMatchers(
// статика
"/css/**",
"/js/**",
"/fonts/**",
"/images/**"
);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question