분류 전체보기
-
Spring MVC01 - DB연결하기Web/Spring 2023. 6. 28. 16:11
- 프로젝트 폴더에서 WEB-INF아래에 appServlet폴더에 servlet-context.xml과 root-context.xml은 스프링에서 아주 중요한 설정파일이다. -Servlet-context.xml: dispatcherServlet이 읽음, dispatcherServlet이 해야할 일을 설정해둔 파일 - root-context.xml : spring 구동시 가장 먼저 실행되는 일들을 설정해둔 파일이다. ContextLoaderListener가 읽는다. - 위와 같이 xml파일들은 api들이 읽어서 무언가를 하도록 미리 설정해둔 파일들이다. - web.xml -> rootcontext->servlet-context 순서 (각 xml파일들은 위치나 이름 바꿔도 됨 *단 web.xml에 잘 등록 ..
-
Spring (1) - 기존 servlet-jsp와 차이점Web/Spring 2023. 6. 28. 14:43
- Spring MVC만들기 > sts3을 통해서 Spring MVC Project를 만들었다. > Spring은 maven(프로젝트 관리도구)으로 툴로 생성-빌드-배포 된다. (디렉토리 구조도 maven이 만들어준다) > 프로젝트 생성시 패키지명의 끝이 context path로 등록된다. ex com.mycompas.myapp -> /myapp > 스프링 mvc프로젝트를 만들면, 기본적인 mvc구조가 미리 갖춰져있다. > 기존 servlet-Jsp와 크게 3가지 차이점이 있다.pojo,라이브러리관리,DB관리 등의 변동이다. Spring과 servlet-jsp MVC와 차이점 1 @HandlerMapping (pojo의 변동) - 기존에 요청 당 존재했던 pojo가 스프링에서는 1개의 pojo에 여러 메..
-
Servlet-JSP MVC07(3) - Ajax 파일업로드Web/Servlet-JSP 2023. 6. 27. 13:27
> 비동기 통신을 통해 파일을 업로드 해볼 것이다. 1. 화면구성, DB수정,VO 수정 1.1 파일첨부 화면 띄우기 첨부파일: 1.2 DB 수정,VO수정 > 회원가입시 파일을 첨부하는 예제이므로, member별 첨부파일이 있는 것이다. > 따라서 DB에 회원별 회원이 저장한 file이름을 함께 저장할 수 있도록 새 table을 만들자 > VO 또한 filename을 속성으로 가지고 있도록 수정해두자. create table member2( num int primary key auto_increment, id varchar(20) not null, pass varchar(20) not null, name varchar(30) not null, age int not null, email varchar(30)..
-
Servlet-JSP MVC07 (2) - ajax로 JSON 다루기Web/Servlet-JSP 2023. 6. 26. 22:28
- 멤버 list.do에서 버튼을 만들어서 번튼을 누르면 회원 목록이 나오도록 고쳐보자. - 이때 버튼을 누르면 서버와 통신하여 member의 정보를 화면전환 없이 가져와야하므로 비동기 통신이 필요 1. List만들기 1.1 버튼 만들기 회원보기 Panel Body Panel Footer function memberList(){ $.ajax({ url : "", type : "GET", dataType : "json", success : resultList, error : function(){ alert("error");} }); } > 부스트 트랩을 이용하여 버튼을 만들었다. > 토글을 클릭하면, memberList()가 실행된다. - 서버와의 통신 결과 json을 응답으로 받는다. - 따라서 {[{m..
-
Servlet-JSP MVC07 (1) - Ajax를 활용한 id 중복확인Web/Servlet-JSP 2023. 6. 25. 23:23
- memberRegister.jsp에서 ID를 중복확인을 할 것이다. - 이때 비동기처리 기술인 Ajax를 활용하여 화면전환 없이 서버로부터 요청과 응답을 받을 것이다. 1. memberRegister.jsp에 id중복확인 버튼 추가 및 ajax 작성 function doublecheck(){ if($("#id").val() ==''){ alert("아이디를 입력하세요"); $("#id").focus(); return } var id=$("#id").val(); $.ajax({ url : "", type : "POST", data : {"id" : id}, success :dbCheck, //함수(callback함수) error: function(){alert("error");} }); } *el과 제..
-
Servlet-JSP MVC06 (3) - 기타 설정Web/Servlet-JSP 2023. 6. 24. 10:37
1. MemberContent.jsp화면을 수정했다. 상세화면 ${sessionScope.userName}님이 로그인 하셨습니다. 안녕하세요 번호: 아이디: 비밀번호: 이름: 나이: 이메일: 전화번호: 변경사항 1.1 로그인 유무에 따라 memberContent.jsp 상단에 뜨는 메세지를 다르게 하였다. ${sessionScope.userName}님이 로그인 하셨습니다. 안녕하세요 1.2 로그인 유무에 따라 수정하기 버튼을 띄우고, 로그인 id와 상세정보의 id가 같을 때만 수정하기 버튼이 활성화 되도록 변경하였다. 1.3 form태그의 submit을 javascript로 만들어서 form태그 밖에서 subimt할 수 있도록 하였다. > document.form1 -> 현재페이지.폼명 2. member..
-
Servlet-JSP MVC06 (2) - 로그아웃 처리와 여러설정Web/Servlet-JSP 2023. 6. 24. 09:56
- session을 이용한 로그아웃 처리를 해보자 - 또한 로그인 시에만 memberList page에서 자신의 정보만 삭제할 수 있고 타인의 정보는 삭제할 수 없도록 변경해보자. 1. 로그인 시 로그인 창 안뜨고, 유저명과 로그아웃 버튼 나오도록 변경하기 //로그인 화면 ${sessionScope.userName}님 반갑습니다. 로그아웃 로그인 시에 session에 userId를 검사하여 다음과 같이 변경한 것이다. > 로그인시 로그인창은 안뜨고, 로그아웃버튼과 유저명이 화면에 나타남 > 로그인 x시 로그인창이 뜸 2. 삭제버튼, 회원가입버튼, 회원가입 시 등록버튼 -리스트 삭제버튼 adisbled속성을 이용하여, 세션에 등록된 userId와 list Page에 등록된 id를 검사하여 로그인아이디와 l..
-
Servlet-JSP MVC06 (1) - Session을 이용한 로그인 처리Web/Servlet-JSP 2023. 6. 24. 09:05
- Sesstion을 이용하여 로그인 처리를 구현해보자. - 먼저 로그인을 위한 화면을 간단하게 만들어보자 회원관리 시스템 ID: Password: 로그인 ${sessionScope.userName}님 환영합니다. 로그아웃 -로그인 구현 1 유효성 check 로그인 로그인 버튼을 누르면, 먼저 유효성을 검사하도록 check()함수를 넣었다. return값이 true일때만 submit이 정상 작동할 것이다. function check(){ if($("#user_id").val() ==''){ alert("아이디를 입력하세요"); return false; } if($("#passward").val()==''){ alert("비밀번호를 입력하세요"); return false; } return true; } c..