0👍
Try the below code to load static files.
@Configuration
//@EnableWebMvc
public class MvcConfig extends WebSecurityConfigurerAdapter implements WebMvcConfigurer {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry
.addResourceHandler("/resources/**")
.addResourceLocations("/resources/");
}
@Override
protected void configure(HttpSecurity http) throws Exception {
String[] resources = new String[]{
"/",
"/home",
"/css/**",
"/icons/**",
"/images/**",
"/resources/**",
"/static/**",
"/js/**"
};
http.csrf().disable();
http.authorizeRequests()
.antMatchers(resources).permitAll()
.and()
.formLogin()
.loginPage("/login")
.loginProcessingUrl("/authenticateTheUser")
.defaultSuccessUrl("/dashboard")
.permitAll();
}
}
And call it in your html page like .
<script src="http://localhost:8080/myproject/resources/vau.js"></script>
Hope this will solve the issue.
Source:stackexchange.com