Spring boot
-
Spring Boot 에서 thymeleaf-layout-dialect 라이브러리를 사용하여 Thymeleaf 템플릿 엔진에 레이아웃을 설정한다. 기본적인 Spring Boot Thymeleaf 설정은 아래 URL을 통해 설정해주세요https://okimaru.tistory.com/255 Spring Boot Thymeleaf 설정1. Spring Boot Project 생성 2. Spring Boot Thymeleaf dependency 추가 2-1. pom.xml 에 dependency 추가 org.springframework.boot spring-boot-starter-thymeleaf 2-2. Maven Update pom.xml에 thymeleaf..okimaru.tistory.com 1...
Spring Boot Thymeleaf Dialect Layout 설정Spring Boot 에서 thymeleaf-layout-dialect 라이브러리를 사용하여 Thymeleaf 템플릿 엔진에 레이아웃을 설정한다. 기본적인 Spring Boot Thymeleaf 설정은 아래 URL을 통해 설정해주세요https://okimaru.tistory.com/255 Spring Boot Thymeleaf 설정1. Spring Boot Project 생성 2. Spring Boot Thymeleaf dependency 추가 2-1. pom.xml 에 dependency 추가 org.springframework.boot spring-boot-starter-thymeleaf 2-2. Maven Update pom.xml에 thymeleaf..okimaru.tistory.com 1...
2022.10.06 -
Date 형식을 원하는 표현형식으로 표현( Date > Date Format ) dates.format(날짜, 형식); String Date형식을 원하는 Date 형식으로 표현( String > Date Format) temporals.format(날짜, 형식);
Thymeleaf th:text Date formatDate 형식을 원하는 표현형식으로 표현( Date > Date Format ) dates.format(날짜, 형식); String Date형식을 원하는 Date 형식으로 표현( String > Date Format) temporals.format(날짜, 형식);
2022.06.15 -
Spring Boot 에서 Form 태그를 사용하여 Post 방식으로 데이터를 넘길때 415 에러가 난다. 간단하게 테스트를 위해 Spring Boot + Thymeleaf 템플릿 엔진을 설정하여 진행하였다. Controller package com.example.demo; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.spri..
Form 태그 데이터 DTO 바인딩(Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported)Spring Boot 에서 Form 태그를 사용하여 Post 방식으로 데이터를 넘길때 415 에러가 난다. 간단하게 테스트를 위해 Spring Boot + Thymeleaf 템플릿 엔진을 설정하여 진행하였다. Controller package com.example.demo; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.spri..
2022.06.15 -
1. Spring Boot Project 생성 2. Spring Boot Thymeleaf dependency 추가 2-1. pom.xml 에 dependency 추가 org.springframework.boot spring-boot-starter-thymeleaf 2-2. Maven Updatepom.xml에 thymeleaf dependency 를 추가했으므로 의존성 및 필요한 라이브러리를 추가하기 위해 Maven update 실행Project 오른쪽 마우스 클릭 > Maven > Update Project Update Project 클릭 시 아래와 같은 화면해당 프로젝트 클릭 후(자동클릭) OK 버튼 클릭 3. View 설정을 위한 application.yml 설정 추가기본적으로 src/..
Spring Boot Thymeleaf 설정1. Spring Boot Project 생성 2. Spring Boot Thymeleaf dependency 추가 2-1. pom.xml 에 dependency 추가 org.springframework.boot spring-boot-starter-thymeleaf 2-2. Maven Updatepom.xml에 thymeleaf dependency 를 추가했으므로 의존성 및 필요한 라이브러리를 추가하기 위해 Maven update 실행Project 오른쪽 마우스 클릭 > Maven > Update Project Update Project 클릭 시 아래와 같은 화면해당 프로젝트 클릭 후(자동클릭) OK 버튼 클릭 3. View 설정을 위한 application.yml 설정 추가기본적으로 src/..
2022.05.31 -
@RequestBody 와 @ModelAttribute 어노테이션은 클라이언트 측에서 보낸 데이터를 Java 에서 사용할 수 있도록 데이터 자동 바인딩 해주는 어노테이션이다. @RequestBody 클라이언트가 보내는 HTTP 요청 본문(Body안의 JSON 및 XML 데이터)을 Java Object로 변환하는 것이다. HTTP 요청 본문 데이터는 Spring에서 제공하는 HttpMessageConverter를 통해 타입에 맞는 객체로 변환된다. 특징 - @RequestBody를 사용하면 요청 본문의 JSON, XML, Text 등의 데이터가 적합한 HttpMessageConverter를 통해 파싱되어 Java 객체로 변환된다. - @RequestBody를 사용할 객체는 필드를 바인딩할 생성자나 Sett..
@RequestBody 와 @ModelAttribute@RequestBody 와 @ModelAttribute 어노테이션은 클라이언트 측에서 보낸 데이터를 Java 에서 사용할 수 있도록 데이터 자동 바인딩 해주는 어노테이션이다. @RequestBody 클라이언트가 보내는 HTTP 요청 본문(Body안의 JSON 및 XML 데이터)을 Java Object로 변환하는 것이다. HTTP 요청 본문 데이터는 Spring에서 제공하는 HttpMessageConverter를 통해 타입에 맞는 객체로 변환된다. 특징 - @RequestBody를 사용하면 요청 본문의 JSON, XML, Text 등의 데이터가 적합한 HttpMessageConverter를 통해 파싱되어 Java 객체로 변환된다. - @RequestBody를 사용할 객체는 필드를 바인딩할 생성자나 Sett..
2022.05.25 -
Thymeleaf 템플릿 엔진에서 ajax 요청 등 Api 요청 URL 앞에 붙여야할 어플리케이션 ContextPath를 사용해야할 때가 있다. 이때 Thymeleaf 속성을 사용하여 ContextPath를 설정하고 변수명으로 호출하여 사용할 수 있다. 보통 Thymeleaf dialect 라이브러리를 사용하여 Layout을 맞추므로 dialect 기준으로 예시를 보여드립니다. 항상 화면에 보여지는 header 부분에 아래와 같은 코드를 추가한다. http 요청 정보에서 getContextPath() 메서드를 사용하여 정보를 가져온다.Thymeleaf 템플릿 엔진이기 때문에 위 th: 구문은 꼭 써야한다. 또는 application.properties 나 application.yml 에 설정한 cont..
Thymeleaf Javascript 에서 ContextPath 가져오기Thymeleaf 템플릿 엔진에서 ajax 요청 등 Api 요청 URL 앞에 붙여야할 어플리케이션 ContextPath를 사용해야할 때가 있다. 이때 Thymeleaf 속성을 사용하여 ContextPath를 설정하고 변수명으로 호출하여 사용할 수 있다. 보통 Thymeleaf dialect 라이브러리를 사용하여 Layout을 맞추므로 dialect 기준으로 예시를 보여드립니다. 항상 화면에 보여지는 header 부분에 아래와 같은 코드를 추가한다. http 요청 정보에서 getContextPath() 메서드를 사용하여 정보를 가져온다.Thymeleaf 템플릿 엔진이기 때문에 위 th: 구문은 꼭 써야한다. 또는 application.properties 나 application.yml 에 설정한 cont..
2022.05.18