공부한 것 정리하려고 만든 블로그

  • [SpringBoot] SpringSecurity 무한 redirect 발생

    홈페이지 메인페이지에 접속했더니 로그인 페이지가 무한 redirect 돼서 오류가 발생했다. 기존코드 - SecurityConfig @Bean SecurityFilterChain filterChain(HttpSecurity http) throws Exception { http .csrf((csrfConfig) -> csrfConfig.disable() ) // csrf 토큰 비활성화 (테스트시 걸어두는게 좋음) .authorizeHttpRequests((authorize) -> authorize .requestMatchers("/", "/auth/**", "/js/**", "/css/**", "/img/**").permitAll() .anyRequest() .authenticated() ) .formLo..

  • [Springboot] 블로그 만들기 (41)_ 댓글 삭제

    detail.jsp 댓글 리스트 ${ reply.content } 작성자 : ${ reply.user.userName } 삭제 board.js let index = { init: function() { } , replyDelete: function(boardId, replyId) { $.ajax({ type: "DELETE", url: `/api/board/${boardId}/reply/${replyId}`, dataType: "json" }).done(function(resp) { alert("댓글 삭제가 완료되었습니다."); location.href = `/board/${boardId}`; }).fail(function(error) { alert(JSON.stringify(error)); }); } ..

  • [Springboot] 블로그 만들기 (40)_ 회원가입, 게시글 삭제 문제 해결

    문제점 : 회원가입시에 중복아이디에 대해서 회원가입이 되는것처럼 동작한다. 하지만 실제로 DB에는 반영이 안된다. GlobalExceptionHandler 회원가입완료 버튼을 눌러서 오류가 발생하게 되면 GlobalExceptionHandler를 타게 된다. 그리고 500을 반환한다. --> 500을 응답했을 경우에 대해서 분기처리를 하면 된다. @ControllerAdvice // 어느파일에서나 Exception이 발생해도 이 함수를 타게 하기 위한 어노테이션 @RestController public class GlobalExceptionHandler { @ExceptionHandler(value=Exception.class) public ResponseDto handleArgumentException..

  • [Springboot] DI(Dependency Injection) 3가지 방법

    방법 1 기본원리 @Service public class BoardService { public BoardService(BoardRepository bRepo, ReplyRepository rRepo) { this.boardRepository = bRepo; this.replyRepository = rRepo; } } 방법 2 @AutoWired 사용 @Service public class BoardService { @Autowired private UserRepository userRepository; @Autowired private BoardRepository boardRepository; @Autowired private ReplyRepository replyRepository; } 방법 3 @r..

  • [Springboot] 블로그 만들기 (39)_댓글 작성하기 (네이티브 쿼리 사용)

    BoardApiController @PostMapping("/api/board/{boardId}/reply") public ResponseDto replySave(@RequestBody ReplySaveRequestDto replySaveRequestDto) { boardService.댓글쓰기(replySaveRequestDto); return new ResponseDto(HttpStatus.OK.value(), 1); } BoardService @Transactional public void 댓글쓰기(ReplySaveRequestDto replySaveRequestDto) { replyRepository.mSave(replySaveRequestDto.getUserId(), replySaveRequest..