목록웹개발 (46)
주뇽's 저장소
JUnit4를 이용하여 Controller 기능을 테스트 하는 도중에 책에서 나온 부분과 실제 함수가 달라 오류가 발생했다. URL 요청에 들어온 파라미터가 제대로 들어왔는지 체크하기 위해 jsonPath 함수를 사용하는데 기존 책은 다음과 같이 작성되어 있다. package com.spring_jyp_todo.springbootTodoProject.controller; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; import org.springf..
JDBC와 Spring JDBC를 이용한 코드 비교 - JDBC(Delete) public void deleteTodo(int id){ PrepareStatement st = null; try{ st = db.conn.prepareStatement("delete from todo where id=?"); st.setInt(1, id); st.execute(); } catch (SQLException e){ logger.fatal("Query Failed :, e"); } finaaly { if (st != null){ try{st.close();} catch (SQLException e){} } } } - Spring JDBC(Delete) public void deleteTodo(int id){ jdb..
Spring Framework Modules 모듈설명 Spring Core IoC(Inversion of Control) 컨테이너, 의존성 주입, 자동 연결 등 애플리케이션의 기본적인 구성 요소를 제공한다. Spring MVC 웹 애플리케이션 및 REST API 개발을 위한 MVC(Model-View-Controller) 패턴을 구현한다. Spring WebFlux 비동기 방식의 리액티브 애플리케이션을 구축할 때 사용한다. Spring JDBC 데이터베이스 작업을 추상화하여 SQL 작업을 간소화한다. Spring JMS Java Message Service를 사용하여 메시징 기반 애플리케이션을 개발할 때 사용한다. Spring TEST 테스팅을 위한 풍부한 기능을 제공하여, 단위 테스트와 통합 테스트를 ..
Spring 의존성 주입 방법 3가지 - 생성자 기반 (Bean) @Autowired 생성자 기반은 해당 어노테이션이 의무가 아니다. Spring 팀은 하나의 메서드에서 모든 초기화가 진행되는 생성자 주입을 항상 추천한다.! @Component class myClass{ Dependency1 dependency1; Dependency2 dependency2; // @Autowired 생성자 기반은 해당 어노테이션이 의무가 아니다. public myClass(Dependency1 dependency1, Dependency2 dependency2) { this.dependency1 = dependency1; this.dependency2 = dependency2; } public String to_Strin..
Spring Bean이란, Spring 프레임워크에서 관리하는 객체이며 여기서 말하는 관리란 객체의 생성, 생명주기, 그리고 그 객체에 대한 요청들을 처리한다는 의미이다. 1. Launch a Spring Context var context = new AnnotationConfigApplicationConext(2번에서 미리설정한configuration.class); 2. 원하는이름Configuration.java 파일 생성 후 @Configuration 어노테이션을 이용하여 Bean 생성 @Bean public String name(){ return "HONG"; } 3. context.getBean("name") 을 통해 전역변수로 설정된 Bean을 확인 할 수 있다! 스프링이 관리하고자 하는 객체들..
PreView Sign Up ⇒ Create View View Info ⇒ Read View(Detail View) Change Info ⇒ Update View Quit ⇒ Delete View Authentication Sign Up → Create view Sign Up → Create view accountapp/views.py 코드 수정 from django.shortcuts import render from django.http import HttpResponse, HttpResponseRedirect **from django.urls import reverse, reverse_lazy from django.views.generic import CreateView from django.cont..
account/model.py 코드 수정 from django.db import models # Create your models here. class HelloWorld(models.Model): text = models.CharField(max_length=25, null=False) migrate 명령어로 앱이 필요로 하는 테이블 생성 python manage.py makemigrations python manage.py migrate 쉘 스크립트를 이용하여 데이터베이스에 데이터 저장 및 조회 python manage.py shell 앱에 있는 모델 import from accountapp.models import HelloWorld HelloWorld 모델로 모델 데이터 만들기 from djang..
static과 CSS는 웹 개발에서 중요한 개념으로, 웹 페이지의 디자인과 스타일을 관리하는 데 사용된다. 1. Static 파일 웹 애플리케이션은 주로 HTML, CSS, JavaScript 등의 파일로 구성된다. 이 중에서 static 파일은 웹 페이지의 정적인 자원들을 저장하는 위치를 나타내는 개념이다. 정적인 자원은 서버에서 변하지 않는 파일로, 예를 들어 이미지, 스타일시트(CSS), 자바스크립트 파일 등이 있다. 장고에서 static 파일은 애플리케이션의 정적인 자원을 관리하기 위한 디렉토리이다. 일반적으로 애플리케이션 디렉토리 내에 static 디렉토리를 만들어 관련 자원을 저장한다. 이렇게 하면 개발자가 웹 페이지의 스타일, 이미지 및 스크립트와 같은 자원을 쉽게 참조하고 관리할 수 있다...