【发布时间】:2021-02-16 10:46:26
【问题描述】:
下面,我使用 login.html 作为在/static/images/ 中添加图像test.png 的页面
所以,在 login.html 中,我有 <img src="../static/images/test.png" width="1000" th:src="@{images/test.png}"/>,它给出了一个空白图像。为什么不显示?
在我的SecurityConfiguration.java 文件中,我有
@Override
protected void configure(final HttpSecurity http) throws Exception {
http
.csrf().disable()
.authorizeRequests()
//.antMatchers("/**").hasRole("ADMIN")
.antMatchers("/static").permitAll()
.and().formLogin()
.loginPage("/login")
.permitAll();
当我使用这个配置时,它使用默认的 index.html 页面,可以很好地显示图像。但是,如果我取消注释 .antMatchers("/**").hasRole("ADMIN"),它会将我带到 login.html,但我无法查看图像。
【问题讨论】:
-
看起来不错..(新)资源可能没有被拾取...干净的构建可能会解决这个问题