Spring
-
API 키 숨기기 ( Spring Legacy 에서 properties 이용하기 )Spring 2023. 5. 14. 22:23
API key나 아이디 , 비밀번호 같이 프로젝트를 하다보면 숨겨야할 정보들이 있다. 이번에는 spring legacy project에서 해당 정보들을 .properties 파일에 저장해서 사용하고, 깃허브에는 .properties 파일을 gitignore 파일에 추가해서 개인정보가 유출되지 않도록 할 것이다. 먼저, src/main/resources 경로에 .properties 파일을 생성하자 src/main/resources 경로는 classpath 라고도 한다. root-context , servlet-context 설정 root-context와 servlet-context에 PropertyPlaceholderConfigurer 를 사용할 수 있도록 Bean을 설정한다 사용하기 원하는 propert..
-
gitignore 생성 ( spring legacy )Spring 2023. 5. 14. 18:03
지난번 팀 프로젝트 때, gitignore 파일을 생성하지 않아서 팀원들이 commit 할 때 pom.properties이 저장소에 저장되는 바람에 version이 맞지 않아 골치아픈 경우가 생겼었다. 이번에는 spring legacy project를 생성하고 pom.properties 파일을 gitignore 파일에 추가해서 이런 불상사를 막아보자. 방법 생성한 프로젝트를 git 저장소와 연동하면, team 탭이 활성화 되고, 무시하고자 하는 파일을 다음과 같이 눌러서 지정하면 된다. 다음의 경로에 gitignore이 자동으로 생성되고, 무시할 파일의 이름이 추가되어 있다. 이제는 pom.properties 파일을 추가하고 commit 해도 자동으로 무시할 것이다. ** 이미 git에 올라가 있는 파일..
-
게시판 파일첨부 ( 2. DB에 저장 및 detail에 Attach )Spring 2023. 4. 14. 15:14
DB에 파일 데이터 저장 및 게시글에 불러오기 : 게시글 쓰기에서 파일을 객체화하고 임시 폴더에 저장하므로써 데이터를 저장할 준비를 마쳤다. 이번에는 기존에 있던 게시글 form에 append 된 파일 객체를 함께 submit 하고 port_attach 테이블에 저장할 것이다. 1 ) BoardVO 변경 기존에 있던 BoardVO에 AttachFileVO 를 ArrayList형태로 저장할 수 있는 필드를 선언했다. 이로서, BoardVO를 매개변수로 선언하면 AttachFileVO 객체 형태의 데이터를 배열로 저장해서 전달할 수 있다. 2 ) Controller, Service Controller와 Service 는 기존과 동일한 형태다 다만, BoardVO내부에 AttachFileVO가 추가되어있다. ..
-
게시판 파일 첨부 (1. 파일을 임시 보관소에 저장하기 )Spring 2023. 4. 14. 15:09
게시판 글쓰기에 파일 첨부 및 파일 불러오기 : 유저들이 게시글에 파일을 첨부하거나 이미지를 불러올 수 있는 기능을 구현해보자. 사실, 이 부분은 textarea의 에디터를 사용하면 더욱 편리하고, 유저가 원한는 위치에 배치 하는 것도 가능하다. 하지만, 스프링에서 해당 기능을 구현해보는 것에 의의를 둔다. 파일을 임시 보관소에 저장하기 : 보내고자 하는 파일을 게시글 작성 브라우저에 미리 등록 시킨 다음 게시글 작성 버튼을 클릭하면 게시글 본문과 함께 데이터베이스에 저장하는 기능을 구현할 것이다. 1) jsp 작성 , AttachFileVO.java 작성 그러기 위해서 upload할 파일을 불러오는 버튼과 임시 저장소로 전송하는 버튼, 임시 저장소에 저장 된 파일을 미리 확인할 수 있도록 썸네일을 불러..
-
ajaxSpring 2023. 4. 10. 10:51
ajax란? : Asynchronous JavaScript and XML의 약자로 자바스크립트 라이브러리 중 하나이다. 웹 페이지 전체를 다시 로딩하기 않고도 웹 페이지의 일부분만을 갱신할 수 있으며, 백그라운드 영역에서 서버와 통신하며 그 결과를 웹 페이지의 일부분에 표시할 수 있다. 따라서 비동기식 방법으로 클라이언트와 서버 간에 XML 데이터를 주고받는 기술이다. ( Json이나 Xml 두가지 형태로 데이터를 갱신할 수 있다. ) ** 비동기 방식은 웹 페이지에서 요청이 있지 않는 상황에서도 프로그램이 계속 돌아가고 있다. 그렇기 때문에, 처리 방식도 빠르고 화면을 리로드 하는 경우 필요한 부분의 리소스만 가져올 수 있다. -> JavaScript를 통해 백 그라운드에서 데이터의 처리와 브라우저에 ..
-
회원가입, 로그인, 게시판 백엔드 실습( 댓글 리스트 , pagenation )Spring 2023. 4. 6. 15:03
댓글 리스트 , pagenation 작성하기 : get 방식으로 데이터베이스에 있는 데이터를 조회하고 JavaScript로 데이터를 브라우저에 나타낼 것이다. 1) JavaScript 작성 $(document).ready(function(){ var board_noValue=$("input[name='board_no']").val(); var pageValue=1; // detail.jsp가 시작되자마자 댓글목록리스트(list) 함수를 호출 list({board_no:board_noValue,page:pageValue}); // 페이지네이션의 페이지를 클릭하면 해당 페이지의 댓글을 호출 $("#replyPage").on("click","li a",function(e){ alert("aaa") e.prev..
-
회원가입, 로그인, 게시판 백엔드 실습( 댓글 작성 )Spring 2023. 4. 6. 14:51
댓글 작성하기 : 댓글 작성의 목표는 유저가 작성한 댓글(content) 와 댓글의 번호, session에 저장되어 있는 아이디를 댓글 table에 비동기식 함수를 사용해서 저장할 것이다. 1) JavaScript 작성하기 $(document).ready(function(){ var board_noValue=$("input[name='board_no']").val(); $("#add").on("click",function(){ var contentValue=$("#content").val(); // 댓글쓰기를 하기 위한 함수 호출 add({board_no:board_noValue,content:contentValue}); }) } function add(reply){ $.ajax({ type:"post"..
-
Spring의 동기식 / 비동기식Spring 2023. 4. 6. 14:25
Sping의 동기/비동기식 통신 방식 기본적인 통신방식 웹 브라우저 -> Controller -> .jsp 동기식 통신방식 - 회원가입 페이지로 이동 웹 브라우저 -> MemberController(Controller) -> Member.jsp(회원가입 화면으로 이동) - 회원가입 버튼을 클릭 웹 브라우저 -> MemberController(Controller) -> MemberVO(model 회원가입 정보 수집) -> MemberService(Service) -> MemberMapper(mapper(dao)) -> Member Table insert - 로그인 페이지로 이동 웹 브라우저 -> MemberController(Controller) -> Login.jsp(회원가입 화면으로 이동) - 로그인 ..