在该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/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)
任何建议将被认真考虑。
这有效:
我变了
<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.png
HTML 代码时,它不会执行,还会sonar
发出警告。
归档时间: |
|
查看次数: |
4021 次 |
最近记录: |