๋ฌธ์ ๋ฐ์
HTML5 ํ์คํ ๋ฆฌ ๋ชจ๋
vue-router
์ ๊ธฐ๋ณธ ๋ชจ๋๋ hash mode ๋ก, URL ํด์๋ฅผ ์ฌ์ฉํ์ฌ ์ ์ฒด URL ์ ์๋ฎฌ๋ ์ดํธ ํ๋ฏ๋ก URL์ด ๋ณ๊ฒฝ๋ ๋ ํ์ด์ง๊ฐ ๋ค์ ๋ก๋ ๋์ง ์๋๋ค...!?
#
ํด์๋ฅผ ์ ๊ฑฐํ๊ธฐ ์ํด ๋ผ์ฐํฐ์ history
๋ชจ๋๋ฅผ ์ฌ์ฉํ ์ ์๋ค.
SPA(Single Page Application)
ํน์ฑ์ vue๋ index.html ํ์ผ ํ๋๋ก ๊ด๋ฆฌํ๋ค.
๊ธฐ๋ณธ์ ์ผ๋ก URL ์ ์
๋ ฅํ๋ฉด ์๋ฒ์ ์์ ๋จผ์ ์๋ํ๊ธฐ๋๋ฌธ์
์๋ฒ์ค์ ์ด ์๋ ํด๋ผ์ด์ธํธ ์ฑ์ด๋ผ ์ฌ์ฉ์๊ฐ ์ง์ URL ์ ์ ์ํ๋ฉด
404 ์๋ฌ๊ฐ ๋ฐ์ํ๋ค.
ํด๊ฒฐ๋ฐฉ์
- ์๋ฒ์ ๊ฐ๋จํ๊ฒ ํฌ๊ด์ ์ธ ๋์ฒด ๊ฒฝ๋ก๋ฅผ ์ถ๊ฐํ๊ธฐ๋ง ํ๋ฉด๋๋ค!
SPA ์ฑ์ ์๋ index.html ํ์ด์ง๋ฅผ ๋งคํํ๋๋ก ํ๋ฉด ๋๋ค.
==> ๋ชจ๋ ์์ฒญ์ ์๋ฒ์์ index.html ์ ๋ฐํํ๊ธฐ ๋๋ฌธ์ ํด๋น ํ์ด์ง์ ๋ด์ฅ๋ SPA ๋ผ์ฐํ ๊ธฐ๋ฅ์ ์ด์ฉํ ์ ์๊ฒ ๋๋ค. - vue ํ๋ก์ ํธ๋ฅผ ๋น๋ํ์ฌ SpringBoot ํ๋ก์ ํธ์ ์ ์ ์์์ ๊ด๋ฆฌํ๋ ๊ฒฝ๋ก์ ๋น๋๋ ํ์ผ๋ค์ ๋ฃ์ด์ค๋ค.
1. SpringBoot
ErrorHandler ์ค์
๋ฐฉ๋ฒ 1
- application.properties ์ค์ ์
- Controller ์์ static ์์ด /index.html ๋ง ํ์ ๊ฐ๋ฅ
๋ฐฉ๋ฒ 2
- application.properties ์ค์ ์ํ ์ /static/index.html ๋ช ์ํด์ผํ๋ค.
์ด๋ ๊ฒํ๋ฉด 404 ์๋ฌ๊ฐ ๋ฐ์ํ์ ์ ๋น๋๋ SPA ์ฑ index.html
๋ก ๋ฐํ ํ๋ค.
resources ํด๋ ๊ตฌ์กฐ
2. Vue.js
vue.config.js ์ค์
module.exports = {
outputDir: "../src/main/resources/static",
indexPath: "../static/index.html",
devServer: {
overlay: false,
historyApiFallback: true,
proxy: {
'/': {
target: 'http://localhost:8080/',
changeOrigin: true,
secure: false
}
}
},
}
SpringBoot ์ ์ ์ ํด๋์ ๋น๋ ๋๋๋ก path ๋ฅผ ์ ์ง์ ํด์ผํ๋ค.
์ด๋ ๊ฒ ๊ฐ๋จํ๊ฒ๋ง ์ธํ ํ๋ฉด ์๋ก๊ณ ์นจ ๋๋ URL์ ์ง์ ์ ๋ ฅํด๋ ์๋ฒ์์ ๋ฐํํ index.html ์์ ๋ผ์ฐํ ํ์ฌ ํ์ด์ง๋ฅผ ์ฐพ์์ค๋ค.
๋ฐ์ํ
'์ค๋ฅ ๋ฐ ํด๊ฒฐ' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
Access denied for user 'root'@'localhost' ํด๊ฒฐ (0) | 2023.02.16 |
---|---|
[JUnit] command line is too long. shorten command line for or also for junit default configuration (0) | 2022.10.05 |
Address already in use : bind ํด๊ฒฐ (0) | 2022.09.01 |
๋๊ธ