[์คํ๋ง ๋ถํธ/MVC] ์ ์ ๋ฆฌ์์ค(Static Resources) ๊ธฐ๋ณธ ์ค์ ๊ณผ ์ปค์คํ ๋ฐฉ๋ฒ [์คํ๋ง ๋ถํธ/MVC] ์ ์ ๋ฆฌ์์ค(Static Resources) ๊ธฐ๋ณธ ์ค์ ๊ณผ ์ปค์คํ ๋ฐฉ๋ฒ ์คํ๋ง ๋ถํธ๋ ์ ์ ๋ฆฌ์์ค(static resources)์ ๋ํ ๊ธฐ๋ณธ ๋งคํ ์ค์ ๊ณผ ์ปค์คํ ์ ์ง์ํ๋ค. ์ค์ ๋ก ํ์ธํด๋ณด์. ์คํ๋ง ๋ถํธ ํ๋ก์ ํธ์ src/main/resources/static/์ hello.html์ ์๋ก ๋ง๋ ๋ค. Hello Static Resource ์ ์ ๋ฆฌ์์ค๋ ์ดํ๋ฆฌ์ผ์ด์ ์ ์ฌ๊ธฐ๋ํ์ง ์๊ณ ๋น๋ํ๋ ๊ฒ ๋ง์ผ๋ก ๋ณ๊ฒฝ์ฌํญ์ ํ์ธํ ์ ์๋ค. ํ๋ก์ ํธ ๋น๋ ํ http://localhost:8080/hello.html๋ก ์์ฒญํด๋ณด์. ์ ์ ๋ฆฌ์์ค ๋งคํ URL ํจํด ๊ธฐ๋ณธ์ ์ผ๋ก /**(๋ฃจํธ) ๋ถํฐ ๋งคํ๋๋ค. ๋ฐ๋ผ์ ์ ์์ฒ๋ผ http://127.0.0.1:8080/hello.html์ ์์ฒญํ๋ฉด ์ ์ .. 2020. 8. 19. ์คํ๋ง ๋ถํธ์์ ์ฆ์ ์น ๊ฐ๋ฐ์ ์์ํ ์ ์๋ ์ด์ - AutoConfiguration ์คํ๋ง ๋ถํธ์์ ์ฆ์ ์น ๊ฐ๋ฐ์ ์์ํ ์ ์๋ ์ด์ - AutoConfiguration spring-boot-starter-web ์์กด์ฑ์ ์ถ๊ฐํ์ฌ ์คํ๋ง ๋ถํธ ํ๋ก์ ํธ๋ฅผ ๋ง๋ค๊ธฐ๋ง ํ๋ฉด ์ฆ์ ์น ์ดํ๋ฆฌ์ผ์ด์ ๊ฐ๋ฐ์ด ๊ฐ๋ฅํ๋ค. @RestController public class UserController { @GetMapping("/hello") public String hello() { return "hello"; } } ์๋ฌด๋ฐ ์ค์ ์์ด ์ปจํธ๋กค๋ฌ๋ฅผ ๋ง๋ค์ด GET /hello ์์ฒญ์ ๋ํ ํธ๋ค๋ฌ๋ฅผ ๊ตฌํํ์ฌ ๋ฉ์ธ ์ดํ๋ฆฌ์ผ์ด์ (@SpringBootApplication)์ ์คํํ๋ฉด ํด๋น ์์ฒญ์ ์ฒ๋ฆฌํ๋ ์น ์ดํ๋ฆฌ์ผ์ด์ ์ด ๋์ํ๋ค. ์คํ๋ง ๋ถํธ์ ๊ธฐ๋ณธ ์ค์ ์ด๋ ์คํ๋ง ๋ถํธ๊ฐ ์ ๊ณตํ๋ ๊ธฐ๋ณธ ์ค์ ๋๋ฌธ์ ๊ฐ๋ฅํ .. 2020. 8. 19. [Spring MVC] Static Resources(์ ์ ๋ฆฌ์์ค) ์ค์ ๋ฐฉ๋ฒ [Spring MVC] Static Resources(์ ์ ๋ฆฌ์์ค) ์ค์ ๋ฐฉ๋ฒ ์คํ๋ง MVC ์น ํ๋ก์ ํธ๋ ์ ์ ๋ฆฌ์์ค๋ฅผ ๋ ๊ฐ์ง ๋ฐฉ๋ฒ์ผ๋ก ์ค์ ํ ์ ์๋ค. ์คํ๋ง XML ์ค์ ์ ์ฌ์ฉํ๋ ๋ฐฉ๋ฒ๊ณผ WebMvcConfigurer ์ธํฐํ์ด์ค๋ฅผ ์ฌ์ฉํ๋ ๋ฐฉ๋ฒ์ด๋ค. ์์ ๊ฐ์ ํ๋ก์ ํธ ๊ตฌ์กฐ์์ {ํ๋ก์ ํธ ๋ฃจํธ}/src/main/webapp/resources ์์น์ ์ ์ ๋ฆฌ์์ค๋ฅผ ์ค์ ํ๋ค๊ณ ๊ฐ์ ํด๋ณด์. ์ด resources ๋๋ ํ ๋ฆฌ๋ ๋ค์๊ณผ ๊ฐ์ด ์คํ๋ง ์น ์ดํ๋ฆฌ์ผ์ด์ ์ ์ ์ ๋ฆฌ์์ค๋ก ์ค์ ํ ์ ์๋ค. 1. ์คํ๋ง MVC ์ ์ ๋ฆฌ์์ค XML ์ค์ ๋ฐฉ๋ฒ ํ๋ก์ ํธ์์ ์ฌ์ฉํ๋ ์คํ๋ง XML ์ค์ ํ์ผ์(servlet-context.xml ...) ๋ค์ ํ๊ทธ๋ฅผ ์ถ๊ฐํ๋ค. ์คํ๋ง IoC ์ปจํ ์ด๋ XML ์ค์ ํ์ผ mapp.. 2020. 4. 15. [Spring Boot/Spring Web MVC] ViewController๋ฅผ ์ด์ฉํด์ ๋ทฐ ๋งคํํ๊ธฐ [Spring Boot/Spring Web MVC] ViewController๋ฅผ ์ด์ฉํด์ ๋ทฐ ๋งคํํ๊ธฐ @GetMapping("/hello") public String hello() { return "hello"; } ์์ ๊ฐ์ด ํน์ ์์ฒญ url์ ๋ํด ์ปจํธ๋กค๋ฌ ๋ก์ง ์์ด ๋ฐ๋ก ๋ทฐ๋ฅผ ๋ฆฌํดํ๋ ๊ฒฝ์ฐ ViewController๋ฅผ ์ฌ์ฉํด์ ๋ทฐ๋ฅผ ๋งคํํ ์ ์๋ค. @Configuration public class WebConfig implements WebMvcConfigurer { @Override public void addViewControllers(ViewControllerRegistry registry) { registry.addViewController("/hello").setViewName("hell.. 2020. 3. 26. [IntelliJ] ์คํ๋ง ๋ถํธ ์์ด ์คํ๋ง ์น MVC ํ๋ก์ ํธ ๋ง๋ค๊ณ ์ค์ ํ๊ธฐ [IntelliJ] ์คํ๋ง ๋ถํธ ์์ด ์คํ๋ง ์น MVC ํ๋ก์ ํธ ๋ง๋ค๊ณ ์ค์ ํ๊ธฐ โป ์ฌ์ฉ IDE : IntelliJ IDEA 2019.3 Ultimate 1. ์ ํ๋ก์ ํธ ์์ฑ ์ฌ์ฉํ๋ ๋น๋ํด(Maven, Gradle) ๊ธฐ๋ฐ์ ํ๋ก์ ํธ๋ฅผ ์์ฑํ๋ค. ์ ํ๋ก์ ํธ๋ฅผ ์์ฑํ๋ค. 1) ์ฌ์ฉํ ๋น๋ํด ์ ํ - ์ด ๊ธ์์๋ Maven์ ์ฌ์ฉํ๊ฒ ์ต๋๋ค. 2) ์ฌ์ฉํ JDK ์ ํ 3) Next ํด๋ฆญ ํ๋ก์ ํธ ์ ๋ณด๋ฅผ ์ ๋ ฅํ๊ณ Finish๋ฅผ ํด๋ฆญํด์ ํ๋ก์ ํธ ์์ฑ์ ์๋ฃํ๋ค. 2. ํ๋ก์ ํธ ์ธํ 1. Java Compiler ๋ฒ์ ๋ณ๊ฒฝ 2. ํ๋ก์ ํธ์ Web Facet ์ถ๊ฐ 3. war packaging ์ค์ Maven ํ๋ก์ ํธ๋ฅผ ์์ฑํ๋ฉด ๊ธฐ๋ณธ Java Compiler ๋ฒ์ ์ด 1.5๋ก ๋์ด์๊ธฐ ๋๋ฌธ์ ๋ณ๊ฒฝ์ด ํ์ํ๋ค. S.. 2020. 3. 17. ์ด์ 1 ๋ค์