1. VSCode 다운로드

> VSCode 홈페이지에서 다운로드 진행

* 한글 변경 방법

: ctrl + shift + p 로 검색창 실행 > language로 검색해서 Configure Display Langage를 선택 > 한글선택하여 다운로드

2. 하기의 Extension Pack과 lombok 다운로드 후 VSCode reroad

* lombok은 어노테이션 관리해주는 라이브러리로, 반복되는 getter, setter, toString .. 등의 반복 메서드 작성 코드를 줄여주는 코드 다이어트 라이브러리이다

3. spring project 생성

> ctrl + shift + p 로 검색창 실행 > Spring initializr 검색하여 gradle or maven 프로젝트 생성

> 버전, 패키지명, 타입 등 선택하고 dependency 추가하여 생성

* 기본적으로 교육 당시에 하기와 같이 dependency 사용햇엇음 필요한부분 찾아서 추가/삭

4. pom.xml과 application.property 수정

(아래는 교육기관에서 사용햇던거고 변동사항이 생기면 이부분도 바꿔야댐)

> pom.xml에 추가 의존성 주입

<!-- https://mvnrepository.com/artifact/org.bgee.log4jdbc-log4j2/log4jdbc-log4j2-jdbc4.1 -->
		<dependency>
		    <groupId>org.bgee.log4jdbc-log4j2</groupId>
		    <artifactId>log4jdbc-log4j2-jdbc4.1</artifactId>
		    <version>1.16</version>
		</dependency>
		<!-- https://mvnrepository.com/artifact/nz.net.ultraq.thymeleaf/thymeleaf-layout-dialect -->
		<dependency>
		    <groupId>nz.net.ultraq.thymeleaf</groupId>
		    <artifactId>thymeleaf-layout-dialect</artifactId>
		</dependency>

> application.property 설정

#server port 설정
server.port=8080

#thymeleaf 새로고침 여부
spring.thymeleaf.cache=false

# DB 연결정보 설정
spring.datasource.driver-class-name=net.sf.log4jdbc.sql.jdbcapi.DriverSpy
spring.datasource.url=jdbc:log4jdbc:mysql://localhost:3306/testdb?serverTimezone=UTC&characterEncoding=UTF8
spring.datasource.username=testid
spring.datasource.password=testpw

#mybatis 설정
#mapper xml 파일 위치 경로 설정
mybatis.mapper-locations=classpath:mapper/**/*.xml

#DML 동작 후 결과 DATA 매핑을 위한 DTO 축약 설정
mybatis.type-aliases-package=com.test.board.dto

5. 프로젝트 빌드

> MAVEN에서 프로젝트 우클릭 후 package 선택하여 프로젝트 필드

6. maincontroller 잡기

>> main 폴더 내에 패키지 경로 폴더 하위에 controller 폴더 생성

>> resources 폴더 내에 templates 폴더에 메인페이지가될 html파일 생성

>> 실행하여 잡혓는지 확인

'springboot' 카테고리의 다른 글

Spring-Boot 환경설정  (0) 2023.05.15
thymeleaf로 레이아웃 관리(fragment)  (0) 2023.05.15
thymeleaf(타임리프)  (0) 2023.05.15
Spring - Maven  (0) 2023.05.15
스프링부트(Spring Boot), Spring MVC  (0) 2023.05.15

1. 새로운 작업환경설정

- 작업 폴더생성

- UTF-8로 환경 설정

- html 템플릿 수정

- thymeleaf플러그인 설치

help > install new software > work with 부분에 플러그인 주소입력

(http://www.thymeleaf.org/eclipse-plugin-update-site/) > 라이센스 허용 > install anyway > restart

 

2. 파일생성

- 기존 작업파일의 해당 폴더 복사해오기

- pom.xml 수정

1) thymeleaf layout dialect 사용하기(fragment 끼워넣기)

https://mvnrepository.com/

> thymeleaf layout dialect

> 버전선택

> Maven 의존성 스크립트 코드 복사

> pom.xml의 dependencies 내부에 해당 코드 삽입 (버전 생략시 최신버전으로 자동 다운로드)

<!-- https://mvnrepository.com/artifact/nz.net.ultraq.thymeleaf/thymeleaf-layout-dialect -->
		<dependency>
		    <groupId>nz.net.ultraq.thymeleaf</groupId>
		    <artifactId>thymeleaf-layout-dialect</artifactId>
		</dependency>
	</dependencies>

2) log4j 사용하기(프로젝트 의존성 추가)

> pom.xml의 dependencies 내부에 해당 코드 삽입

<!-- https://mvnrepository.com/artifact/org.bgee.log4jdbc-log4j2/log4jdbc-log4j2-jdbc4.1 -->
		<dependency>
		    <groupId>org.bgee.log4jdbc-log4j2</groupId>
		    <artifactId>log4jdbc-log4j2-jdbc4.1</artifactId>
		    <version>1.16</version>
		</dependency>
	</dependencies>

- application.properties 설정

#server port 설정
server.port=80

#thymeleaf 새로고침 여부
spring.thymeleaf.cache=false

# DB 연결정보 설정
spring.datasource.driver-class-name=net.sf.log4jdbc.sql.jdbcapi.DriverSpy
spring.datasource.url=jdbc:log4jdbc:mysql://localhost:3306/ksmart43db?serverTimezone=UTC&characterEncoding=UTF8
spring.datasource.username=ksmart43id
spring.datasource.password=ksmart43pw

3. MainController 생성 및 동작 확인

package com.test.mybatis.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

@Controller
public class MainController {

	/*
	 * 메인화면 index
	 * @return index.html 논리적경로 
	 */
	@GetMapping("/")
	public String index() {
		return "index";
	}
}

> run as 동작확인

'springboot' 카테고리의 다른 글

VSCode에서 SpringBoot 사용하기  (1) 2023.05.23
thymeleaf로 레이아웃 관리(fragment)  (0) 2023.05.15
thymeleaf(타임리프)  (0) 2023.05.15
Spring - Maven  (0) 2023.05.15
스프링부트(Spring Boot), Spring MVC  (0) 2023.05.15

1. thymeleaf - fragment

- fragments를 이용해서 레이아웃을 분리하고 확장 라이브러리를 이용하여 하나의 템플릿을 기준으로 끼워넣는 방식의 페이지 처리가 가능 >>> 모든 페이지마다 th:insert가 사용될 필요가 없음

>>> 반드시 dependency 태그 안쪽에 위치해야한다. 버전을 생략할 시 자동으로 최신버전으로 다운로드해준다.

- 프로젝트 내에 fragment폴더를 생성하여 각 부분의 html 파일 작성

- 분리된 fragments 파일을 하나로 합칠 layout 폴더 및 파일 생성

- head부분 작성

<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
	  xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">
	<head th:fragment="headFragment">
		<meta charset="UTF-8">
		<title>ksmart43</title>
		
		<!-- thymeleaf 링크 표현 구문 @{} -->
		<link rel="stylesheet" type="text/css" th:href="@{/css/main.css}">
		
		<!-- 사용자 정의 css -->
		<th:block layout:fragment="customCss"></th:block>

		<!-- 사용자 정의 js -->
		<th:block layout:fragment="customJs"></th:block>
	</head>
</html>

>>> 확장라이브러리를 사용하기 때문에 html 부분에

xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" 태그를 추가로 사용한다

 

- header 부분 작성

<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
	<div id="header" th:fragment="headerFragment">
		head.html<br>
		상단메뉴<br>
		<a href="#">01회원가입</a>
		<a href="#">02회원목록</a>
		<a href="#">03상품등록</a>
		<a href="#">04상품목록</a>
	</div>
	
</html>

- leftmenu 부분 작성

<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
	<div id="leftcolumn" th:fragment="leftmenuFragment">
		left.html <br><br>
		왼쪽메뉴
	</div>
</html>

- footer 부분 작성

<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
	<div id="footer" th:fragment="footerFragment">
		footer.html<br>
		하단메뉴<br>
		063-717-1008-ksmart.or.kr 한국스마트정보교육원
		
	</div>
	
</html>

- contents 부분 작성

<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
	  xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
	  layout:decorate="~{layout/default}">
	
	<!-- 사용자 정의 css -->
	<th:block layout:fragment="customCss">
	
	</th:block>

	<!-- 사용자 정의 js -->
	<th:block layout:fragment="customJs">
		<script src="http://code.jquery.com/jquery-latest.min.js"></script>
	</th:block>
	
	<!-- 사용자 정의 contents -->
	<th:block layout:fragment="customContents">
		<!-- $ : 모델의 값을 바인딩하는 구문 -->
		<!-- ${key} : 태그의 속성에서 값을 바인딩하는 구문 -->
		<h1 th:text="${title}"></h1>
		<!-- [[${key}]] : 인라인 스타일 -->
		[[${title}]]
		[[${member}]]
	</th:block>
</body>
</html>

 

- 통합 default 부분 작성

<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
	  xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">
<head th:replace="fragments/head :: headFragment"></head>
<body>
	<div id="wrapper">
		<div th:replace="fragments/header :: headerFragment"></div>
		<div th:replace="fragments/leftmenu :: leftmenuFragment"></div>
		<div id="rightcolumn">
			<!-- 사용자 정의 contents -->
			<th:block layout:fragment="customContents"></th:block>
		</div>
		<div th:replace="fragments/footer :: footerFragment"></div>
		
	</div>
</body>
</html>

- 확인

'springboot' 카테고리의 다른 글

VSCode에서 SpringBoot 사용하기  (1) 2023.05.23
Spring-Boot 환경설정  (0) 2023.05.15
thymeleaf(타임리프)  (0) 2023.05.15
Spring - Maven  (0) 2023.05.15
스프링부트(Spring Boot), Spring MVC  (0) 2023.05.15

1. thymeleaf

- view 템플릿엔진으로써 controller가 전달하는 데이터를 이용하여 동적으로 화면을 구성하도록 도와줌.

- html 태그를 기반으로하여 동적인 View를 제공한다.

- th:속성을 이용하여 데이터를 바인딩한다 (ex. th:text="${변수명}"의 형태로 사용)

- 별도의 라이브러리 서버의 내부에서 처리되는 템플릿으로 별도의 라이브러리가 필요하다.

- application.properties변경 -> spring.thymeleaf.cache = false

- DevTool을 이용한 즉시 리로딩 기능 선택

- 이클립스에서 편집기능을 기본으로 제공하지않기 때문에 추가적인 플러그인 설치가 필요하다.

*** 플러그인 설치방법 ***

1. install New Software 선택

2. work with 부분에 플러그인 주소입력 (http://www.thymeleaf.org/eclipse-plugin-update-site/)

3. 상세설치 내용확인 후 Next / 라이센스 동의 후 finish

4. 보안경고가 나오면 install anyway 를 선택하여 설치

5. 재시작

************************************

1) 폴더/파일 생성

- static 폴더 : js, css, html, 이미지 파일 등을 추가하는 폴더

- templates폴더 : 내부에 thymeleaf를 이용한 템플릿 저장

2) controller 작성

3) thymeleaf를 이용한 템플릿 작성

>>> html단에 xmlns:th="http://www.thymeleaf.org" 부분 필수이기 때문에 시트 template에 미리 작성하기

4) thymeleaf 실습

1. 객체 출력하기

package ksmart.thymeleaf.dto;

public class Member {
	private String memberId;
	private String memberPw;
	private String memberLevel;
	private String memberEmail;
	private String memberAddr;
	
	@Override
	public String toString() {
		return "Member [memberId=" + memberId + ", memberPw=" + memberPw + ", memberLevel=" + memberLevel
				+ ", memberEmail=" + memberEmail + ", memberAddr=" + memberAddr + "]";
	}

	public Member(String memberId, String memberPw, String memberLevel, String memberEmail, String memberAddr) {
		super();
		this.memberId = memberId;
		this.memberPw = memberPw;
		this.memberLevel = memberLevel;
		this.memberEmail = memberEmail;
		this.memberAddr = memberAddr;
	}

	public String getMemberId() {
		return memberId;
	}
	public void setMemberId(String memberId) {
		this.memberId = memberId;
	}
	public String getMemberPw() {
		return memberPw;
	}
	public void setMemberPw(String memberPw) {
		this.memberPw = memberPw;
	}
	public String getMemberLevel() {
		return memberLevel;
	}
	public void setMemberLevel(String memberLevel) {
		this.memberLevel = memberLevel;
	}
	public String getMemberEmail() {
		return memberEmail;
	}
	public void setMemberEmail(String memberEmail) {
		this.memberEmail = memberEmail;
	}
	public String getMemberAddr() {
		return memberAddr;
	}
	public void setMemberAddr(String memberAddr) {
		this.memberAddr = memberAddr;
	}
}

//controller 부분
@GetMapping("/exam1")
	public String exam1(Model model) {
		Member member = new Member("id001", "pw001", "관리자"
				, "홍01@ksmart.or.kr", "전주시 덕진구 기린대로446");
		
		model.addAttribute("member", member);
		
		return "exam/exam1";
	}

//thymeleaf 템플릿
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>exam1</title>
</head>
<body>
	<!-- thymeleaf 객체 바인딩 -->
	<h1 th:text="${member}"></h1><br>
	<!-- 객체에 담겨진 멤버변수 바인딩 -->
	<!-- 객체에 담겨진 멤버변수명과 바인딩할 멤버변수명이 일치되어야한다. -->
	<h1 th:text="${member.memberId}"></h1>
</body>
</html>

>>> dto 부분 먼저작성하고 해당부분 controller작성 후 thymeleaf 템플릿 작성

2. 리스트 출력하기

*** th:each - status ***

1. index : 0부터 시작하는 인덱스 번호

2. count : 1부터 시작하는 번호

3. size : 현재 대상의 length 혹은 size

4. odd/even : 현재 번호의 홀수/짝수 여부(true/false)

5. first/last : 처음요소인지 마지막 요소인지 판단

//controller 부분
@GetMapping("/exam2")
	public String exam2(Model model) {
		
		List<Member> memberList = new ArrayList<Member>();
		Member member = null;
		for(int i=1; i<10; i++) {
			if(i%3 == 1) {
				member = new Member("id00"+i, "pw00"+i, "관리자"
						, "홍0"+i+"@ksmart.or.kr", "전주시 덕진구 기린대로446");
			}else if(i%3 == 2) {
				member = new Member("id00"+i, "pw00"+i, "관리자"
						, "홍0"+i+"@ksmart.or.kr", "전주시 덕진구 기린대로446");
			}else {
				member = new Member("id00"+i, "pw00"+i, "관리자"
						, "홍0"+i+"@ksmart.or.kr", "전주시 덕진구 기린대로446");
			}
			memberList.add(member);
		}
		model.addAttribute("memberList", memberList);
		
		return "exam/exam2";
	}

//thymeleaf 템플릿
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>exam2</title>
</head>
<body>
	<table border="1">
		<thead>
			<tr>
				<th>회원아이디</th>
				<th>회원비밀번호</th>
				<th>회원권한</th>
				<th>회원이메일</th>
				<th>회원주소</th>
			</tr>
		</thead>
		<tbody>
			<!-- each구문 = l : 배열객체의 약어(변수), l : ${배열} 형태로 사용 -->
			<tr  th:each="l : ${memberList}">
				<td th:text="${l.memberId}">
				<td th:text="${l.memberPw}">
				<td th:text="${l.memberLevel}">
				<td th:text="${l.memberEmail}">
				<td th:text="${l.memberAddr}">
			</tr>
		</tbody>
	</table>
	<table border="1">
		<thead>
			<tr>
				<th>index</th>
				<th>count</th>
				<th>size</th>
				<th>odd/even</th>
				<th>first/last</th>
			</tr>
		</thead>
		<tbody>
			<!-- each구문뒤에 ,변수명 부분은 해당 변수명으로 배열의 상태를 알아보기 위함이다. -->
			<tr  th:each="l, status : ${memberList}">
				<td th:text="${status.index}">
				<td th:text="${status.count}">
				<td th:text="${status.size}">
				<!-- odd/even : 각각 홀수 짝수 여부 확인ㅇ  -->
				<td th:text="${status.odd + '/' + status.even}">
				<td th:text="${status.first + '/' + status.last}">
			</tr>
		</tbody>
	</table>
</body>
</html>

3. th:with을 이용한 지역변수 선언

//controller 부분
@GetMapping("/exam3")
	public String exam3(Model model) {
		
		List<Member> memberList = new ArrayList<Member>();
		Member member = null;
		for(int i=1; i<10; i++) {
			if(i%3 == 1) {
				member = new Member("id00"+i, "pw00"+i, "관리자"
						, "홍0"+i+"@ksmart.or.kr", "전주시 덕진구 기린대로446");
			}else if(i%3 == 2) {
				member = new Member("id00"+i, "pw00"+i, "관리자"
						, "홍0"+i+"@ksmart.or.kr", "전주시 덕진구 기린대로446");
			}else {
				member = new Member("id00"+i, "pw00"+i, "관리자"
						, "홍0"+i+"@ksmart.or.kr", "전주시 덕진구 기린대로446");
			}
			memberList.add(member);
		}
		model.addAttribute("memberList", memberList);
		
		return "exam/exam3";
	}

//thymeleaf 템플릿
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>exam3</title>
</head>
<body>
	<!-- thymeleaf 지역변수 선언 및 초기화 -> th:with, 지역변수 범위는 선언된 태그가 닫힐 때 까지 -->
	<table border="1" th:with="target='id001'">
		<thead>
			<tr>
				<th>회원아이디</th>
				<th>회원비밀번호</th>
				<th>회원권한</th>
				<th>회원이메일</th>
				<th>회원주소</th>
			</tr>
		</thead>
		<tbody>
			<!-- 주석부분도 문법오류 발생시 오류가발생하므로 주의할 것 -->
			<!-- <tr>
				<td colspan="5">[[${target}]]</td>
			</tr> -->
			
			<!-- th:block : jsp에서의 <% %>와 같다 -->
			<th:block th:if="${target eq 'id002'}">
				<tr>
					<td colspan="5" th:text="${target}"></td>
				</tr>
			</th:block>
			<th:block>
				<tr  th:each="l : ${memberList}">
					<!-- thymeleaf 조건문 : th:if(조건식 true), th:unless(조건식 false) -->
					<td th:if="${l.memberId eq target}" th:text="${l.memberId}">
					<td th:unless="${l.memberId eq target}" th:text="${l.memberId}">
					<td th:text="${l.memberPw}">
					<td th:text="${l.memberLevel}">
					<td th:text="${l.memberEmail}">
					<td th:text="${l.memberAddr}">
				</tr>
			</th:block>
		</tbody>
	</table>
</body>
</html>

4. 날짜, 숫자관련

//controller 부분
@GetMapping("/exam4")
	public String exam4(Model model) {
		model.addAttribute("now", new Date());
		model.addAttribute("price", 123456789);
		return "exam/exam4";
	}

//thymeleaf 템플릿
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>exam4</title>
</head>
<body>
	<!-- thymeleaf utility Object -->
	<h1 th:text="${now}"></h1>
	<th:block th:with="currentDate = ${#dates.createToday()}">
		<h1 th:text="${currentDate}"></h1>
	</th:block>
	<h1 th:text="${#dates.format(now, 'yyyy-MM-dd HH:mm:ss')}"></h1>
	<h1 th:text="${price}"></h1>
	<h1 th:text="${#numbers.formatInteger(price, 3, 'COMMA')}"></h1>

	<!-- utility Object를 활용한 단순 반복문 -->
	<th:block th:each="num : ${#numbers.sequence(1, 10)}">
		<h1 th:text="${num}"></h1>
	</th:block>
	
	
	
</body>
</html>

'springboot' 카테고리의 다른 글

VSCode에서 SpringBoot 사용하기  (1) 2023.05.23
Spring-Boot 환경설정  (0) 2023.05.15
thymeleaf로 레이아웃 관리(fragment)  (0) 2023.05.15
Spring - Maven  (0) 2023.05.15
스프링부트(Spring Boot), Spring MVC  (0) 2023.05.15

1. Maven

- 자바 프로젝트의 빌드를 자동화해주는 빌드툴

- 라이브러리의 관리를 용이하게 해줌

- 필요한 라이브러리를 특정문서(pom.xml)에 정의해놓으면 네트워크를 통해서 자동으로 다운받아줌

1) Maven 기반 웹프로젝트 기본 디렉터리 구조

2) 구성요소

1. pom.xml(필수요소) : 프로젝트 정보가 표시되며, 스프링에서 사용되는 여러가지 라이브러리를 설정해서

자동으로 다운로드를 도와주는 문서

2. src/main/jajva : 자바 소스파일이 위치

3. src/main/resource : 프로퍼티, xml 파일 등 리소스 파일이 위치

4. src/main/webapp : WEB_INF 등 웹 애플리케이션 리소스 위치

5. src/test/java : Junit 등 테스트 파일이 위치

6. src/test/resource : 테스트 시 필요한 resource 파일이 위치

>>> mvnrepository에 궁금한 내역 검색

3) pom.xml 구조

*** 메이븐 프로젝트 라이브러리 충돌 발생시 해결방법 ***

  1. 해당 프로젝트 우클릭 -> MAVEN -> update project -> force 추가체크 후 확인
  2. sts종료 후 -> C\USER\해당아이디\.m2\repository\모든폴더 -> 전체삭제

'springboot' 카테고리의 다른 글

VSCode에서 SpringBoot 사용하기  (1) 2023.05.23
Spring-Boot 환경설정  (0) 2023.05.15
thymeleaf로 레이아웃 관리(fragment)  (0) 2023.05.15
thymeleaf(타임리프)  (0) 2023.05.15
스프링부트(Spring Boot), Spring MVC  (0) 2023.05.15

1. 스프링 부트

- 스프링 프레임워크를 기반으로 한 개발 플랫폼

- 단독실행 가능한 스프링 애플리케이션 생성

- 프로젝트 환경을 구축할 때 필요한 톰캣, 제티, 언더토우 내장

- XML 기반 설정이나 코드 없이 환경 설정을 자동화 가능

- 스프링 프레임워크 개발 접근성 용이

1) 스프링 프레임워크 개발단계

1. 사용할 스프링 MVC, JPA, 하이버 네이트의 버전을 결정

2. 모든 다른 레이어를 연결 해주는 스프링 콘텍스트 설정

3. 스프링 MVC로 웹 레이어 설정

4. 데이터 레이어에서 하이버네이트를 설정

5. 단위테스트, 트랜잭션 전략, 로깅, 모니터링 방법 결정 구현

6. 웹 애플리케이션 서버에 배포하는 방법 결정 규현

2) 스프링 작업 툴(STS) 다운로드 및 환경설정

1. https://spring.io/tools 에서 버전에 맞는 툴 다운로드

2. 환경설정

>>> utf-8로 모든 작업환경을 변경한다

3. 파일생성

*** 원래는 도메인 역순으로 그룹명을 짜야된다.현재는 테스트용이라 간략화 시킴 >>> kr.or.ksmart ***

4. Thymeleaf 부분 수정

5. controller만들기

>>> 폴더와 파일 생성

>>> @부분 작성하고 자동완성클릭시 import 자동 작성

>>> @GetMapping 부분에 경로를 매핑해주고 반환값을 설정(member폴더의 memberInfo 파일)

6. 표시할 화면 생성

>>> thymeleaf를 적용하고, body부분에 표시할 값 설정(매핑할 때 설정해 두었던 memberName값 설정)

>>> thymeleaf 구문을 매번 작성하기 힘드니 preference > html > templet > html5 문서를 해당 형식으로

Edit 해준다.

7. 확인

*** 사용후 다시 가동할때 이미 포트가 열려있어서 포트번호 중복이 날수도 있으니 프로젝트를 업데이트

시키거나, cmd에서 taskkill을 진행하고 실행해야한다. ***

>>> 수정 후 재실행하거나 다른 프로젝트를 실행할 시 서버 꼭 종료해야함.

********* spring MVC 동작 순서 정리 *********

개인정리 >>>

1. 브라우저에서 URL을 요청 -> DispathcherServlet이 요청을 받는다.(서버가 DispathcherServlet에 위임)

2. DispathcherServlet이 controller를 식별하기위해 핸들러 매핑과 통신

3. 핸들러 매핑은 요청처리를 위한 특정 핸들러 메서드를 DispathcherServlet에 반환

4. DispathcherServlet에서 반환받은 특정 메서드를 호출

5. 핸들러 메서드에서 model(객체)과 view를 반환

6. DispathcherServlet가 논리적 view를 결정하는 view 리졸버를 찾아 호출

7. 호출된 view 리졸버는 논리적 뷰이름을 물리적 뷰이름에 매핑(경로에 매핑)

8. 매핑된 view는 DispathcherServlet으로 요청된 내용을 반환

9. DispathcherServlet에서 브라우저로 요청한 결과값을 반환

*********************************************

'springboot' 카테고리의 다른 글

VSCode에서 SpringBoot 사용하기  (1) 2023.05.23
Spring-Boot 환경설정  (0) 2023.05.15
thymeleaf로 레이아웃 관리(fragment)  (0) 2023.05.15
thymeleaf(타임리프)  (0) 2023.05.15
Spring - Maven  (0) 2023.05.15

+ Recent posts