0

I have a Boot Application with Java Configuration but without ThymeLeaf and I am having trouble referencing CSS in my JSP page. When I start up the application, I see this in Browser Console.

localhost/:1 Refused to apply style from 'http://localhost:8080/SheridanSports/css/nav.css' because its MIME type ('application/json') is not a supported stylesheet MIME type, and strict MIME checking is enabled.

This is the structure of the Project

enter image description here

index.jsp

<head>
    <title>Spring Sports-Home</title>
    <base href="/">
    <link href="${pageContext.request.contextPath}/css/nav.css" rel="stylesheet" type="text/css">
</head>

AppConfig.java

@Configuration
@EnableWebMvc
//@ComponentScan(basePackages = "com.abc.SheridanSportsWAR")
public class AppConfig implements WebMvcConfigurer{
    
    @Bean
    public ViewResolver viewResolver() {
        
        InternalResourceViewResolver bean = new InternalResourceViewResolver();
        
        bean.setPrefix("/WEB-INF/view/");
        bean.setSuffix(".jsp");
        
        return bean;
    }   
}
Abhay
  • 167
  • 3
  • 16

0 Answers0