2022-03-15(화)

Jeongyun Heo·2022년 3월 15일
0

Server-side rendering과 client-side rendering

① Server-side rendering : 서버측에서 UI(HTML, CSS, JavaScript)를 만들어 준다.

서버에 요청을 하면 스프링부트가 작업을 하고
그 결과를
작업에는 데이터 처리가
HTML 생성
그리고 응답을 하는데
서버에서 동적으로 UI 생성
이 방식의 대표적인 예가 JSP

완성된 HTML을 주면
웹 브라우저에 HTML을 렌더링(출력)

SI 프로젝트에서 주로 사용하는 방식

② Client-side rendering

보통 서비스 업체에서 쓰는 방법

서비스 업체에서 주로 사용하는 방식

작업할 때 데이터 처리
HTML을 생성하는 게 아니라
JSON 또는 XML 생성 (데이터 생성)
예) Front-end/Back-end 분리
서버에서 JSON 또는 XML를 응답한다
웹 브라우저는 JSON 또는 XML 데이터를 가지고
JavaScript를 통해 HTML을 동적으로 생성

ContactDao에 MyBatis 적용하기

Contact 데이터를 저장할 테이블을 생성한다

create table ml_contact(
  contact_no int not null,
  name varchar(50) not null,
  tel varchar(50) not null,
  email varchar(20) not null,
  company varchar(50)
);
alter table ml_contact
  add constraint primary key (contact_no),
  modify column contact_no int not null auto_increment;

자동생성하는 코드가 다 이런 식으로 되어 있음

exerd로 자동생성

package com.eomcs.mylist.dao;

import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import com.eomcs.mylist.domain.Contact;

@Mapper
public interface ContactDao {

  // 인터페이스는 객체의 메서드 호출 규칙을 정의하는 것이기 때문에
  // 메서드를 작성할 때 메서드 몸체(method body)를 작성하지 말아야 한다.
  // 메서드 바디가 없는 메서드를 "추상 메서드(abstract method)"라 부른다.

  int countAll(); // => <select id="com.eomcs.mylist.dao.ContactDao.countAll">...</select>

  List<Contact> findAll();

  int insert(Contact contact);

  Contact findByNo(int no);

  Contact findByEmail(String email);

  List<Contact> findByName(String name);

  int update(Contact contact);

  int delete(int no);

}

DAO 구현체 자동 생성

mybatis framework

패키지랑 폴더랑 일치해야만 자동으로 연결된다

규칙을 정의한 게 contactMap
contact 객체를 여러 개 만들어서
데이터를 저장한 후 그 contact 객체를 리스트에 담아서 리턴한다
누가? MyBatis가

update문 리턴값은 int
리턴타입은 int 아니면 void

create table ml_todo(
  todo_no int not null,
  title varchar(255) not null,
  done boolean default false
);

alter table ml_todo
  add constraint primary key (todo_no),
  modify column todo_no int not null auto_increment;

test04_1.html - web/src/main/resources/static/css

http://localhost:8080/css/test04_1.html

background-color
inherited : no

스타일 적용 순서
specificity 값 : 셀렉터의 우선 순위를 지정하기 위해 부여된 값

같은 점수일 때 나중에 지정된 스타일이 기존 스타일을 덮어쓴다

태그이름에 지정하는 것보다 클래스가 더 우선순위가 높다

인라인 스타일이 가장 우선순위가 높다

아예 우선순위가 높을 때는 순서가 앞쪽이어도

같은 레벨인 경우에는 뒤에 선언한 스타일이 기존 스타일을 덮어쓴다

레벨이 높은 스타일이 적용된다

셀럭터의 레벨에 따라서 결정된다

class : 10 (.c1)
id : 100 (#d2)

div#d3 : 1 + 100 = 101

.c1#d3 : 10 + 100 = 110

http://localhost:8080/css/test04_3.html

#d2 div#d3 : d2의 자손 중에서 id가 d3인 div

border-style: dashed solid;
값이 2개 주어지면 상하 좌우

border-style: dashed double none;
값이 3개 주어지면 상 좌우 하

border-style: dashed groove none dotted;
값이 4개 주어지면 상 우 하 좌 (시계 방향)

http://localhost:8080/css/test05_3.html

display: inline-block; 인라인 태그

display: block;

한 줄에 한 개

inline-block 인라인의 기능을 가진 블럭

width 콘텐트의 너비
height 콘텐트의 높이

padding이 늘어나도 content의 너비는 동일하다

box-sizing: border-box;
기본이 content-box

test06_1.html - web/src/main/resources/static/css

http://localhost:8080/css/test06_1.html

폰트 이름에 띄어쓰기 있으면 폰트를 '', ""로 적기

직접 지정하지 말고 body를 기준으로 비율로 설정하기
xfont-size: 1.2em;
font-size: 150%;

test07_1.html - web/src/main/resources/static/css

background-color를 지정하지 않으면 투명 배경에 이미지가

background-position: left top;
top left로 해도 됨

background-size: 50px;
높이는 그림 비율에 따라 자동 계산된다.

background-size: auto 70px;
너비는 자동 계산된다

한 번에 배경을 설정하기(background)
순서는 상관없음
background: gray url('img01.jpeg') no-repeat right 30px bottom 80px;

test07_7.html
배경 그림을 여러 개 설정하기(background)

콤마를 찍으면
background-size: 100px, 50px;
첫 번째 이미지의 너비, 두 번째 이미지의 너비

서버에서 별도로 다운로드 받아서 넣어야 됨
네트워크 통신하는 시간(비용)이 든다
해결책?
이 이미지를 하나의 파일에 담아버리자

트위터
이모티콘
이미지를 폰트로 만들어서
그 자리에

web open font format

woff viewer

https://fontdrop.info/

http://localhost:8080/css/test07_10.html

\u유니코드
&#16진수

fantasy

그림이 아니라 글자

단, 폰트이기 때문에 단색밖에 안 됨

여러 색을 쓰고 싶으면 이미지 파일로...

h1 태그 안에 있는 값이 그 페이지의 주제

background-image

background style 기법

height: 0px;

overflow: hidden;
넘친 거는 감춰라

background-image는 선택이 안 된다

0개의 댓글