You need help.
I am using spring 4.1 with spring security 3.2.7 and annotations.
My js, css, images are not loading. I get this error.
Spring mvc with protection and access to images and images WEB-INF. Script execution from http: // localhost: 8081 / xyz / static / internal / js / jquery-1.10.2.min.js ' is denied because its MIME type ('text / html') is not executable, and is included strict type checking MIME.
Without spring protection everything works fine
These are the configurations in 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 they are in the security configuration.
@Override
public void configure(final WebSecurity web) throws Exception {
web.ignoring().antMatchers("/WEB-INF/pages/static/**");
web.ignoring().antMatchers("/resources/**");
}
and 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>
- - web.ignoring().antMatchers("/WEB-INF/pages/static/**");
.
, .