전체 글
-
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(회원가입 화면으로 이동) - 로그인 ..
-
회원가입, 로그인, 게시판 백엔드 실습( 게시판 디테일 )Spring 2023. 4. 5. 15:37
게시판 리스트에서 게시글의 제목을 클릭하면 디테일로 이동할 수 있게 만들었다. : 디테일로 이동하면 하나의 게시글에 대한 상세 정보를 볼 수 있고, 이를 수정 / 삭제할 수 있는 기능을 넣을 것이다. 1. Controller @Controller public class BoardController { @Autowired BoardService bs; // 게시글 Detail @RequestMapping(value = "/board/detail", method = RequestMethod.GET) public String detail (BoardVO board, Model model) { model.addAttribute("detail", bs.detail(board)); return "board/deta..
-
회원가입, 로그인, 게시판 백엔드 실습( 게시판 글쓰기 )Spring 2023. 4. 5. 15:35
게시판 글쓰기 : 게시글을 데이터베이스에 추가할 수 있는 기능을 만들 것이다. 이 때 로그인한 아이디에 대한 정보를 게시글에 남긴다. 1. Controller // 게시판 글쓰기 데이터 저장 @RequestMapping(value="/write", method = RequestMethod.POST) public String writePost(BoardVO board) { System.out.println(board); bs.write(board); return "redirect:/board/list"; } - BoardVO 객체에 게시판에 대한 정보를 담아서 데이터베이스에 저장할 것이다. public class BoardVO { private int board_no; private String title..
-
회원가입, 로그인, 게시판 백엔드 실습( 게시판 리스트 )Spring 2023. 4. 5. 15:23
데이터 베이스에 저장되어있는 데이터를 게시판에 나타내자. 1. Controller // 게시판 메인 @RequestMapping(value="/board/list", method = RequestMethod.GET) public String list (Model model, CriteriaVO cri) { model.addAttribute("list", bs.list(cri)); int total=bs.total(cri); model.addAttribute("paging", new PageVO(cri, total)); return "board/list"; } - bs.list() 함수의 결과로 게시글에 대한 정보를 ArrayList에 담아오고 - bs.total() 의 결과로 게시글의 총 량을 int 타..
-
HTTP 상태 415 – 지원되지 않는 Media Type기타 2023. 4. 5. 12:42
게시글에 댓글을 입력할 수 있는 기능을 추가하려고 했으나 위의 에러가 발생했다. - Controller 내부의 @RequestBody 매개변수를 선언하고 return값을 ResponseEntity로 받는다고 선언헀는데, 이는 해당 코드를 비동기식으로 처리하겠다는 말이다. 하지만, JSP에서 작성한 form 태그로부터 데이터를 받아오도록 작성 되어있었기 때문에, Header에서 Controller로 데이터가 이동하는 도중 동기, 비동기식 간의 충돌로 인해 해당 에러가 발생했다. 이를 방지하기 위해, 비동기식으로 선언된 controller에는 비동기식으로 생성된 데이터를 보내줘야한다. 따라서, JavaScript에서 비동기식으로 생성된 form을 만들어서 데이터를 보내줄 것이다.
-
회원가입, 로그인, 게시판 백엔드 실습( login 기능 구현 )Spring 2023. 4. 4. 15:49
Login 기능 구현하기 : 회원가입 기능을 이용해서, 데이터베이스에 유저 정보를 저장할 수 있게 만들었다. 이제는 유저가 로그인하기 위해 입력하는 데이터가 회원 데이터베이스 내부에 존재하는지 확인하고 데이터가 내부에 존재한다면 session에 login 기록을 저장하고 존재하지 않는다면, login 화면에 머무르게 만들 것이다. 1 . Login.jsp 구성하기 - logind은 post 방식으로 id와 password에 대한 정보를 받을 것이다. input 태그 내부에 required="" 는 해당 칸이 비었을 경우 submit 기능을 막아주는 것이 원래의 기능이지만, 여기서는 css가 정상적으로 작동하려면 해당 attribute가 꼭 필요하다. 2. Contoller 작성 - Login.jsp의 f..
-
회원가입, 로그인, 게시판 백엔드 실습( login 화면 )Spring 2023. 4. 4. 15:26
로그인화면 구성하기 - 우선은 Spring을 활용해서, 회원가입을 하면 유저의 데이터를 데이터베이스에 저장하고 login 할 때 데이터베이스에 일치하는 데이터가 있다면, session에 로그인 정보를 저장하고 일치하는 데이터가 없다면, 다시 login화면으로 돌아오는 기능을 구현할 것이다. - 유효성 검사는 차후에 진행할 예정 ** 로그인 기능은 MemberController -> LoginService -> LoginServiceImpl -> LoginMapper -> LoginMapper.xml 과정으로 데이터베이스와 연동할 것이다. 1) 로그인 화면에 template 구성하기 - codePen에서 깔끔한 로그인 css를 가져왔고, 회원가입 페이지는 로그인 페이지의 양식을 변경했다. 2) 회원가입 기..