Need a help of following.
I am using spring 4.1 with spring security 3.2.7 and annotations.
My js, css, images are not loading..I am getting this error.
Spring mvc with security and WEB-INF js and images access- Refused to execute script from 'http://localhost:8081/xyz/static/internal/js/jquery-1.10.2.min.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
With out spring security everything is working fine
These are the configurations at mvcconfig.
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/resources/**").addResourceLocations("/", "/resources/");
registry.addResourceHandler("/static/**").addResourceLocations("/", "/WEB-INF/pages/static/");
}
@Bean
public ViewResolver viewResolver() {
final InternalResourceViewResolver bean = new InternalResourceViewResolver();
bean.setViewClass(JstlView.class);
bean.setPrefix("/WEB-INF/pages/");
bean.setSuffix(".jsp");
return bean;
}
and these are at Security configuration.
@Override
public void configure(final WebSecurity web) throws Exception {
web.ignoring().antMatchers("/WEB-INF/pages/static/**");
web.ignoring().antMatchers("/resources/**");
}
and the web.xml is
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
<servlet>
<servlet-name>mvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>mvc</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>localizationFilter</filter-name>
<filter-class>org.springframework.web.filter.RequestContextFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>localizationFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
Very confused- when I am ignoring - web.ignoring().antMatchers("/WEB-INF/pages/static/**");
Why it is not able to load my static contents.
Please help me on this.