분류 전체보기
-
스프링 핵심 원리 (2) - 스프링 컨테이너와 스프링 빈Web/Spring 2023. 8. 17. 12:14
1. 스프링 컨테이너 생성 ApplicationContext applicationContext = new AnnotationConfigApplicationContext(AppConfig.class); - 위와 같이 스프링 컨테이너 생성, ApplicatoinContext는 인터페이스이다. (구현객체 어노테이션~,xml~등) - 스프링 컨테이너는 XML기반 혹은 애노테이션 기반으로 만들 수 있다. 1.1 스프링 컨테이너 생성 과정 - ApplicationContext 구현객체를 생성하면, 스프링 컨테이너에 빈 저장소가 생성되고, 파라미터로 넘어온 구성 정보를 통해 스프링 빈 저장소가 채워진다. - 빈 이름은 메서드명, 빈 객체는 리턴 값으로 채워진다. - 빈 이름은 직접 부여할 수 있다.( @Bean(na..
-
스프링 핵심 원리 (1) - 예제 순수 자바 to 스프링 컨테이너Web/Spring 2023. 8. 16. 18:49
- 객체 지향 프로그래밍의 원리에 맞게 회원 및 주문 서비스를 만들어보자 - 객체 지향 설계에서 협력 - 역할 - 책임의 관계는 매우 중요하다. 역할: 객체가 수행할 책임들을 의미하고, 다형적인 특징을 보여준다. 책임: 객체가 수행해야할 행위 공용인터페이스 - 객체지향- 다형적 특징은 역할과 구현을 분리함으로써 달성할 수 있다. 캡슐화: - 데이터 숨김, 내부 구현 숨김,메시지를 통한 데이터 접근 -> 객체 자율성 부여 - 오류의 범위 캡슐 내부화 -> 유지보수에 유리 타입: 객체를 나누는 기준 -> 할 수 있는 책임(행위)에 따라 객체 분리(classify) 클래스: 객체를 생성할 수 있도록 언어적 차원에서 지원된 정적 객체 생성 방법 - 객체지향적 설계에서 가장 중요한 것은 협력관계를 통해 적절히 책..
-
나프 - 게시판 만들기(1)Web/Spring 2023. 8. 2. 21:05
1. 3-Tier 방식의 이해 - Spring에서 DB 작업 간소화로 사용자 요구사항을 반영하고, 컨트롤러 비대해지는 것을 방지하기 위해 - Presentation Tier Persistence Tire의 3개의 Tire로 나누어 요청을 처리한다. Presentation: 웹/화면 계층, Controller(FrontController+POJO),JSP를 이용한 VIEW구성 담당 Business Tire : 비지니스 계층, 고객 요구사항 반영 로직을 기준으로 처리 (메서드 이름은 현실적인 로직의 이름을 붙이는 것이 관례이다.) 등록,회원검색,수정,삭제 등 Presentation 계층을 통해 메시지를 받고 DB와 협력하여 로직을 처리 Persistence Tire: 영속계층, 데이터에 대한 CRUD VO클..
-
Java - 일급컬렉션언어/JAVA 2023. 7. 25. 11:40
일급컬렉션이란 Collection을 Wrapping하면서, 그 외 다른 멤버 변수가 없는 상태 1.일급컬렉션 적용 규칙 - 일급컬렉션에는 컬렉션 외 다른 멤버변수 없어야한다. - 각 컬렉션은 자체로 포장돼 있음으로, 콜렉션과 관련된 동작 근거지가 마련됨 - 필터가 일급컬렉션 클래스에 일부가 된다. > 필터는 또한 스스로 함수 객체가 될 수 있다. Map map = new HashMap(); map.put("1","A"); //.. 이를 아래와 같이 클래스 안으로 묶음 public class GameRanking{ private Map ranks; public GameRanking(Map ranks){ this.ranks = ranks; } } List carList = new ArrayList(); pu..
-
Servlet-JSP MVC07 파일 수정하기언어/JAVA 2023. 7. 24. 21:23
- 파일 수정하기 - 파일 수정하기도 회원 가입시 첨부파일을 지정하는 것과 마찬가지로 - 파일 업로드하고 정보 수정 vs 파일 업로드 없이 정보 수정 - 파일 업로드하고 회원 정보 수정시 1. ajax로 먼저 파일을 업로드 시키고, 업로드 된 filename 콜백함수로 받아서 2. hidden타입 id= filename에 value를 return받은 filename으로 바꿔 둔 뒤에 3. 수정하기 누르면, 같이 넘어가도록 한다. 1. 뷰 쪽 수정 function update(){ if($("#file").val() != ''){ var formData = new FormData(); formData.append("file",$("input[name=file]")[0].files[0]); $.ajax({ ..
-
Servlet-JSP MVC07 - 파일 삭제 하기Web/Servlet-JSP 2023. 7. 24. 20:52
1. 뷰 설정 삭제 버튼에 a태그로 자바스크립트 메서드 연결시켜두었다. function delFile(num,filename){ location.href="?num="+num+"&filename="+filename; } 삭제를 위한 컨트롤러와 연결 2. fileDeleteController public class FileDelController implements Controller{ @Override public String requestHandler(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String ctx = request.getContextPath(); //파일 이..
-
Java - File클래스언어/JAVA 2023. 7. 24. 12:27
- File은 기본적이면서도 가장 많이 사용되는 입출력 대상이다. - file클래스는 파일 혹은 디렉토리를 다룰 수 있도록 다양한 메서드를 정의하고 있다. 1. File클래스 생성자 * 파일과 디렉토리는 같은 방법으로 다룬다. * pathname에는 보통 경로까지 포함새서 지정해줘야하지만, 프로그램이 실행되는 위치와 파일의 위치가 같을 경우 파일명만 사용해도 된다. File f = new File(//path); File dir = new File(//path); //이미 존재하는 파일을 파일 객체로 참조시 File f = new File(//) //없는 파일을 생성할때 f.createNewFile(); *OutputStream에 경우 해당 스트림을 열고 파일을 쓸 때 파일이 없으면 생성해서 쓴다. (F..
-
Servlet-JSP MVC07 - 파일 다운로드Web/Servlet-JSP 2023. 7. 23. 00:20
> 업로드된 파일을 다시 다운로드 받아보자. 1. MemberContent.jsp설정 파일 이름 출력하는 부분에 a태그를 걸었다. function getFile(filename){ location.href="?filename="+filename; } 파일 다운로드를 처리할 수 있는 컨트롤러로 가도록 설정 2. Controller public class FileGetController implements Controller{ @Override public String requestHandler(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { //파일 읽어올 경로 설정 String f..