Programming/Web-Spring 썸네일형 리스트형 [SpringBoot] html페이지에서 Json 값을 객체로 받아올때 주의사항 model public class Star { String name; int age; public Star(String name, int age) { this.name = name; this.age = age; } } controller // [Request sample] // POST http://localhost:8080/hello/request/form/json // Header // Content type: application/json // Body // {"name":"Robbie","age":"95"} @PostMapping("/form/json") @ResponseBody public String helloPostRequestJson(@RequestBody Star star) { retur.. 더보기 [SpringBoot] @ModelAttribute 값받을때 null값 나오는 현상 model public class Star { String name; int age; public Star(String name, int age) { this.name = name; this.age = age; } } 괄호(String name, int age)가 있는 생성자로 만들고 Controller // [Request sample] // POST http://localhost:8080/hello/request/form/model // Header // Content type: application/x-www-form-urlencoded // Body // name=Robbie&age=95 @PostMapping("/form/model") @ResponseBody public String hello.. 더보기 [Thymeleaf] SpringBoot에 Thymeleaf 적용하기 기존에 JSP환경에서 뷰를 제작하다가 한계를 느껴 다른 템플릿을 적용해보기로 마음을 먹었다. 스프링이 지원해주는 템플릿 엔진을 알아보던 중 FreeMarker Groovy Thymeleaf Mustache 이렇게 4개가 있다는 것을 알게되었는데 그 중에 스프링이 지원해준다는 Thymeleaf(타임리프)를 적용해 보기로 하였다. (사실 처음엔 가장 성능 좋다는 Freemarker를 선택했는데 SpringSecurity프레임 워크를 적용하던 중 막혀서 결국 Thymeleaf를 선택하게 되었다. Freemarker로 SpringSecurity를 적용하려면 JSTL을 별도로 또 사용해야 한다는 의견이 있어서 SpringSecurity까지 사용해야 하는 내 경우에는 타임리프가 낫다는 판단이 들었다.) 1. Bui.. 더보기 [SpringBoot] Spring 프로젝트에서 Thymeleaf 기본 설정하는 방법 먼저, thymeleaf를 설정하는 방법을 소개 한 후, thymeleaf 설정 후 css도 설정하는 방법을 알려드리겠습니다. Thymeleaf 설정하는 방법 STEP 1. build/gradle 파일 설정 아래와 같이 thymeleaf 관련 dependency를 추가합니다. .. dependencies { .. implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' implementation('nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect') }Copy STEP 2. application.properties 설정 아래의 4줄을 추가합니다. spring.thymeleaf.cache=false.. 더보기 [intellij/spring] h2 (메모리영역에서 사용하는db)설정 방법 intellij spring boot 프로젝트 실행 /h2-console 뒷부분 jdbc로 시작하는 문자열 복사 http://localhost:8080/h2-console 이동 jdbc url 에 아까 복사 한 jdbc 값을 붙여넣기 이후 바로 connect 버튼 클릭 db 접속 완료 show databases ; 명령어를 실행해서 되는지 확인해 볼 것 더보기 [intellij] spring 프로젝트 생성 및 시작 사용언어 java + spring framework 툴 : intellij db : h2 빌드 : gradle 1. 프로그램 설치 (실습 용도로 사용) java : jdk 11 version intelliJ : community version 설치 2. 프로젝트 생성 3. build.gradle 설정 plugins { id 'org.springframework.boot' version '2.4.2' id 'io.spring.dependency-management' version '1.0.11.RELEASE' id 'java' } group 'com.web.todo' version '1.0-SNAPSHOT' repositories { mavenCentral() } dependencies { // JPA i.. 더보기 SpringFramework 에서 다국어처리지원하기 스프링 프레임웍에서 다국어 지원기능을 사용해 보겠습니다. 기본적으로 텍스트로 저장되는 properties 파일을 언어별로 만들어서 사용합니다. 이번에 해볼것은 다음과 같습니다. 1. 메세지 프로퍼티 파일을 작성합니다. 2. 스프링프레임웍에서 사용할 수 있도록 설정을 합니다. 3. 언어를 변경할 수 있도록 구현합니다. 4. 자바코드과 jsp 코드에서 다국어 메세지를 사용하는 방법을 알아봅니다. 파일구조는 다음과 같습니다. /WEB-INF/messges 폴더 아래에 메세지를 담은 파일이 있습니다. message.properties 파일은 기본 파일 입니다. 언어가 맞지 않으면 이것이 선택되어질 것입니다. message_ko.properties 파일은 한국어 메세지 파일 입니다.message_en.proper.. 더보기 이전 1 2 다음