<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>dev-jih.log</title>
        <link>https://velog.io/</link>
        <description>즐기는 개발자가 되고 싶어요</description>
        <lastBuildDate>Fri, 09 Jul 2021 18:29:38 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <copyright>Copyright (C) 2019. dev-jih.log. All rights reserved.</copyright>
        <atom:link href="https://v2.velog.io/rss/dev-jih" rel="self" type="application/rss+xml"/>
        <item>
            <title><![CDATA[[bootstrap] Spring boot, thymeleaf 연동시 js, css 파일 경로 인식하지 못하는 404 에러 해결]]></title>
            <link>https://velog.io/@dev-jih/bootstrap-Spring-boot-thymeleaf-%EC%97%B0%EB%8F%99%EC%8B%9C-js-css-%ED%8C%8C%EC%9D%BC-%EA%B2%BD%EB%A1%9C-%EC%9D%B8%EC%8B%9D%ED%95%98%EC%A7%80-%EB%AA%BB%ED%95%98%EB%8A%94-404-%EC%97%90%EB%9F%AC-%ED%95%B4%EA%B2%B0</link>
            <guid>https://velog.io/@dev-jih/bootstrap-Spring-boot-thymeleaf-%EC%97%B0%EB%8F%99%EC%8B%9C-js-css-%ED%8C%8C%EC%9D%BC-%EA%B2%BD%EB%A1%9C-%EC%9D%B8%EC%8B%9D%ED%95%98%EC%A7%80-%EB%AA%BB%ED%95%98%EB%8A%94-404-%EC%97%90%EB%9F%AC-%ED%95%B4%EA%B2%B0</guid>
            <pubDate>Fri, 09 Jul 2021 18:29:38 GMT</pubDate>
            <description><![CDATA[<p>부트스트랩 무료 테마를 다운 받아서 resource/static에 css, js 데이터를 resource/templates에 html 파일을 넣고 빌드 후 실행했을 때 
<code>GET http://localhost:8080/static/js/scripts.js net::ERR_ABORTED 404</code> 에러가 발생했다.</p>
<p><img src="https://images.velog.io/images/dev-jih/post/5c3971c6-815f-49d0-a6ae-5f7d1b48b3c1/img1.png" alt=""></p>
<p>html 파일만 띄워봤을 땐 문제 없이 파일들이 불러와져서 화면에 띄워졌는데 서버로 열면 경로 인식이 안되는 듯 했다.</p>
<p><img src="https://images.velog.io/images/dev-jih/post/c35ba650-884e-4eed-a496-89bb4d676abf/img2.png" alt=""></p>
<p>내가 받은 테마에 경로들이 static 폴더를 포함하고 있던게 문제였다.</p>
<p><img src="https://images.velog.io/images/dev-jih/post/fb6d81b0-5592-4886-bc38-48c0efa14386/img3.png" alt=""></p>
<p>스프링부트의 설정에서 static 폴더가 기본경로로 지정되어있기 때문에 static 밑의 경로만 써주면 된다.</p>
<p>이 코드를
<code>&lt;script src=&quot;../static/js/scripts.js&quot;&gt;&lt;/script&gt;</code></p>
<p>이렇게 바꿔주면 정상적으로 css, js 파일의 경로가 인식된다.
<code>&lt;script src=&quot;/js/scripts.js&quot;&gt;&lt;/script&gt;</code></p>
<p>출처: <a href="https://spring.io/blog/2013/12/19/serving-static-web-content-with-spring-boot">https://spring.io/blog/2013/12/19/serving-static-web-content-with-spring-boot</a></p>
]]></description>
        </item>
    </channel>
</rss>