티스토리 뷰

프로젝트 중 팀원으로부터 한 피드백을 받았다.
장바구니 페이지 이동 시, 크롬 개발자도구 '콘솔' 창에 에러메시지가 발생한다는 제보였다.

 

크롬 개발자 도구 > 콘솔(url : http://localhost:8080/cart)

 

Refused to apply style from '<http://localhost:8080/css/main.css>' 
because its MIME type ('text/html') is not a supported stylesheet MIME type, 
and strict MIME checking is enabled.

 

문제 🎨

위와 같은 에러가 발생하는 이유는 경로를 잘못 적어주었기 때문이다. 

해석하면, 'main.css'라는 스타일시트 파일을 적용할 수 없다는 뜻이다.

<head>
    <%@ include file="/WEB-INF/views/include/header.jsp" %>
    <link rel="stylesheet" href="/css/main.css"/>
    <link rel="stylesheet" href="/css/order/cart.css"/>
    <script src = "/js/order/format.js"></script>
    <title>장보고 | 장바구니</title>
</head>

 

해결방안 🕵️‍♂️

경로를 수정한다.

<head>
    <%@ include file="/WEB-INF/views/include/header.jsp" %>
    <link rel="stylesheet" href="/css/index.css"/>
    <link rel="stylesheet" href="/css/order/cart.css"/>
    <script src = "/js/order/format.js"></script>
    <title>장보고 | 장바구니</title>
</head>

크롬 개발자 도구 > 콘솔(url : http://localhost:8080/cart)

 

레퍼런스 📎

[Spring] css파일을 못찾을때

댓글
공지사항