spring & springboot 4

View 환경설정

- welcome page 기능resources/static 아래에 index.html 파일을 올려두면 Welcome page 기능 제공함.Hellohello 서버를 껐다가 다시켜면 이렇게 잘 뜸. - thymeleaf 템플릿 엔진동작하고 프로그래밍 되는 화면 만들기 첫 진입점이 controller.hello.hellospring 밑에 controller 패키지 생성.controller 패키지 밑에 HelloController 생성. * 애노테이션 @Controller 꼭 붙이기package hello.hellospring.controller;import org.springframework.stereotype.Controller;import org.springframework.ui.Model;import..

라이브러리 살펴보기

build.gradle에 dependencies에는 라이브러리가 몇 개 없지만External Libraries에는 많이 존재.=> 의존 관계. gradle에 추가한 라이브러리가 필요한 라이브러리를 External Libraries로 끌고 옴. - spring-boot-starter-web1. spring-boot-starter-tomcat : 톰캣(웹서버)2. spring-webmvc : 스프링 웹 MVC - spring-boot-starter-thymeleaf : 타임리프 템플릿 엔진(view) - spring-boot-starter(공통) : 스프링 부트 + 스프링 코어 + 로깅* 실무에서는 logging 많이 씀.1. spring-boot spring-core 존재2. spring-boot-star..

프로젝트 생성(환경설정)

-JAVA 11버전 추천 하지만 난 17버전으로 설치되어있는 상태라 이대로 해보기로 했다. 1. start.spring.io들어가서 프로젝트 생성https://start.spring.io/Spring Boot의 SNAPSHOT : 아직 개발 중이라는 뜻M1 : 릴리즈되기 전 ADD DEPENDENCIES를 눌러 라이브러리 선택web project 생성 => Spring Web,템플릿 엔진 => Thymeleaf를 검색하여 선택한다. GENERATE 버튼 누르면 다운받아짐.압축 풀고, Intellij에 프로젝트를 연결시킴 * 테스트 중요함.*build.gradle : spring boot나오면서 start.spring.io덕분에 편하게 할 수 있게 됨.버전 설정하고 라이브러리 땡겨옴.*.gitignore ..

@PathVariable, @RequestParam 등 스프링부트 애노테이션 정리

@PathVariable, @RequestParam, @ModelAttribute모두 Http 요청에 오는 정보들을 컨트롤러의 매개변수로 바인딩할 때 편하게 해주는 애노테이션들 1. @PathVariableURL 템플릿에서 동적으로 변하는 값들을 추출하는데 사용. 주로 리소스 식별자를 얻는데 사용함.ex) users/1 : 식별자가 1인 user를 조회해야할 때 => @PathVariable 사용 2. @RequestParam쿼리 파라미터, 쿼리 스트링이나 폼 데이터를 바인딩할 때 사용ex) users?name=spring: name이 "spring"인 user를 조회해야 할 때 => @RequestParam * 주의@RequestParam을 사용해서 받아오는 변수에 값이 존재하지 않으면 400 erro..

spring & springboot 2024.08.03