Spring 57

0512 spring AOP 중 발생 오류(스케쥴러 동작) java.lang.IllegalStateException: No thread-bound request found:

오류내용: java.lang.IllegalStateException: No thread bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet: In this case, use RequestContextListener or..

Spring 2023.05.12

0512 spring AOP 정의

Spring AOP : Spring AOP 란, 관점 지향 프로그래밍(Aspect Oriented Programming)의 약자로 일반적으로 사용하는 클래스(Service, Dao 등) 에서 중복되는 공통 코드 부분(commit, rollback, log 처리)을 별도의 영역으로 분리해 내고, 코드가 실행 되기 전이나 이 후의 시점에 해당 코드를 붙여 넣음으로써 소스 코드의 중복을 줄이고, 필요할 때마다 가져다 쓸 수 있게 객체화하는 기술을 말한다.

Spring 2023.05.12

spring, java 개행문자(줄바꿈) <br> -> \n replace 처리

// 개행문자 처리 public static String newLineHandling(String content) { return content.replaceAll("(\r\n|\r|\n|\n\r)", " "); } // 개행문자 해제 public static String newLineClear(String content) { return content.replaceAll(" ", "\n"); } --> DB에 저장시 개행문자(줄바꿈)은 "\n"으로 인식하기 때문에 jsp 에서의 enter 즉 개행문자가 태그로 되있는 상태로 인식하게 됩니다. 그래서 표시가 안되는 상황이 나타납니다. ->해결을 위해서는 \n으로 변경이 필요 합니다

Spring 2023.05.12

spring XSS(크로스 사이트 스크립팅)

XSSHandling :크로스 사이트 스크립팅(XSS) 공격을 방지하기 위한 메소드 // 크로스 사이트 스트립트 공격을 방지 하기 위한 메소드 public static String XSSHandling(String content) { if(content != null) { content = content.replaceAll("&", "&"); content = content.replaceAll("", ">"); content = content.replaceAll("\"", """); } return content; } // 크로스 사이트 스트립트 해제 public static String XSSClear(String content) { if(content != null) { content = conten..

Spring 2023.05.12

0509spring 게시물 댓글(3) 댓글 수정 및 삭제

*댓글수정* -ReplyController //댓글 수정 /*url : contextPath + "/reply/update", data : {"replyNo" : replyNo, "replyContent" : replyContent}, type : "POST" */ @PostMapping("/update") public int replyUpdate(@ModelAttribute Reply reply ) { // -> vo객체를 가져올때는 @ModelAttribute reply.getReplyNo(); reply.getReplyContent(); int result = replyservice.replyUpdate(reply); return result; } -ReplyService /**댓글수정 * @par..

Spring 2023.05.11

0509spring 게시물 댓글(2) 댓글 달기(삽입) (대댓글 포함)

*방법1* (Map에 값 담아서 전달하기) -ReplyController //댓글 등록 /* url : contextPath + "/reply/insert", data : {"memberNo" : loginMemberNo, "boardNo" : boardNo, "parentReplyNo" : parentReplyNo, "replyContent" : replyContent}, type : "POST", myPage 비밀번호변경 참고 */ //@RequestParam Map map 선언시 ajax의 data 값 map에 담겨진다 @PostMapping("/insert") public int replyInsert(@RequestParam Map map, @RequestParam(value="parentRepl..

Spring 2023.05.11

spring에러 MethodArgumentTypeMismatchException,NumberFormatException

org.springframework.web.method.annotation.MethodArgumentTypeMismatchException: Failed to convert value of type 'java.lang.String' to required type 'int'; nested exception is java.lang.NumberFormatException: For input string: "delete" Caused by: java.lang.NumberFormatException: For input string: "delete" For input string: "delete" -> 으로 봤을 때 delete 가 버튼이 잘못 되있는것으로 예상되어 확인해보니 jsp 에서 delete button ..

Spring 2023.05.09

resultMap역할과 사용이유 & parameterType,resultType사용

*resultMap 태그의 역할* -SELECT 조회결과(ResultSet)의 컬럼과 조회결과를 옮겨 담을 VO의 필드명이 일치하지 않을 때 이를 매핑시켜 조회결과가 필드에 세팅되게 하는 역할 [resultMap 속성] 1)type :조회결과를 담을 VO의 타입 또는 별칭 ex)mybatis-config에서 만든member 2)id :만들어진 resultMap태그를 지칭할 이름(식별명) *resultMap에 vo를 작성하는 이유* -VO의 필드명과 DB의 조회되는 컬럼명이 일치하면 자동으로 VO객체에 값이 세팅된다 -> java와 DB의 표기법 차이로 인해 위 특징이 적용되는 경우가 거의 없다 ex) vo.Member = memberNo -> DB = MEMBER_NO -> 해결방법 필드명, 컬럼명이 다..

Spring 2023.05.09

spring MVC 요청 처리 과정

DispatcherServlet :클라이언트 요청(Request)을 전달 받고, 요청에 맞는 컨트롤러가 리턴 한 결과값을 View에 전달해 알맞은 응답(Response)을 생성 HandlerMapping :클라이언트 요청 URL을 어떤 컨트롤러가 처리할지 결정 Controller :클라이언트 요청을 처리한 뒤, 결과를 DispatcherServlet에게 리턴 ModelAndView :컨트롤러가 처리한 결과 정보 및 뷰 선택에 필요한 정보를 담음 ViewResolver :컨트럴러의 처리결과를 생성할 View를 결정 View :컨트롤러의 실행결과 화면을 생성, JSP나 velody탬플릿 파일등을 View로 사용

Spring 2023.05.09

0508spring 게시판(5) 글 삭제

boardDetail.jsp ${detail.boardTitle} - ${detail.boardName} ${detail.memberNickname} 작성일 ${detail.createDate} 마지막 수정일 ${detail.updateDate} 조회수 ${detail.readCount} 썸네일 다운로드 업로드 이미지 다운로드 ${detail.boardContent} 수정 삭제 목록으로 board.js // 즉시 실행 함수 : 성능up, 변수명 중복 X (function(){ const deleteBtn = document.getElementById("deleteBtn"); // 존재하지 않으면 null if(deleteBtn != null){ // 버튼이 화면에 존재할 때 deleteBtn.addEve..

Spring 2023.05.09