Written by
spring-style
on
on
4. 정적페이지를 이용한 SpringBoot Project(spring web)
4. 정적페이지를 이용한 SpringBoot Project(spring web)
폴더 만들기
Static은 url이 노출되지 않음으로 css image js파일을 넣을 것임으로 각각의 폴더를 생성하고 templates폴더에는 thymeleaf가 포함되어야 하는 html을 넣어야 인식을 제대로 할 수 있다.
css폴더 안에는 getbootstrap.com에 있는 css를 가져와 사용한다
js폴더 안에는 jquery페이지에 있는 source를 가져와 사용한다.
확인할 html파일 index.html생성
Insert title here $(document).ready(function() { alert("Hello, Spring Boot World!!!"); }); Hello, Spring Boot World ... Learn more
controller가 있는 HomeController 클래스 생성
@Controller public class HomeController { @GetMapping("/") public ModelAndView home(ModelAndView mav) { mav.setViewName("index.html"); return mav; } }
index에 확장자를 붙이게 된다면 정적페이지로 인식하여 작용을 하며 html에 타임리프를 사용하게 된다면 확장자를 붙이지 않으면 된다.
from http://wonho.tistory.com/12 by ccl(A) rewrite - 2021-11-24 00:27:19