본문 바로가기

분류 전체보기275

@ModelAttribute 사용할 때 주의할 점(NULL 값) GetMapping을 사용하면서 파라미터를 DTO로 넣어서 사용할 때 @ModelAttribute를 사용할 때 자주 발생하는 문제점이 있습니다. 파라미터로 했을 때는 잘 들어오던 값들이 Null or 0 으로 들어오는 문제점입니다. 이럴 때는 DTO에 @NoArgsConstructor 를 삭제 혹은 @Setter를 삽입 을 시도해보시면 해결되는 것을 볼 수 있을 겁니다. 저는 개인적으로 DTO에 Setter를 잘 안쓰기 때문에 @NoArgsConstructor 를 삭제하는 편입니다. 끝 2025. 4. 27.
Spring Boot Error - Whitelabel Error Page IDE에서 스프링 부트를 실행하고 localhost:8080(기본)에 접속했을 때 이런 페이지를 볼 때가 있습니다. 이건 시작은 했는데 뭔가 보여줄 게 없거나, 오류가 있어서 나오는 페이지입니다. '/' 요청을 처리해주는 컨트롤러가 없거나, 기본 index.html이 없는 경우가 많고요. 혹은 진짜 에러가 발생했을 수 있습니다. 일단 저는 여기서 테스트용으로 '/'을 처리해주는 컨트롤러를 만들어보겠습니다. import org.springframework.web.bind.annotation.GetMapping;import org.springframework.web.bind.annotation.RestController;@RestControllerpublic class TestController { .. 2025. 4. 26.
입국심사 - Python, 이진탐색 https://school.programmers.co.kr/learn/courses/30/lessons/43238 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr  코드 & 풀이 def solution(n, times): left = 1 right = max(times) * n answer = right while left = n: answer = mid right = mid - 1 else: left = mid + 1 return answer  right를 최악으로 가정 최악 = 심사.. 2025. 4. 6.
2169번 로봇 조종하기 - Python, DP 출처 : https://www.acmicpc.net/problem/2169 코드 import sys# 입력 처리data = sys.stdin.read().splitlines()N, M = map(int, data.pop(0).split(" "))mars = [list(map(int, data.pop(0).split(" "))) for _ in range(N)]dp = [[[-float('inf')] * 3 for _ in range(M)] for _ in range(N)]# 첫 번째 행 초기화dp[0][0][0] = dp[0][0][1] = dp[0][0][2] = mars[0][0]for y in range(1, M): dp[0][y][0] = dp[0][y][1] = dp[0][y][2] = d.. 2025. 4. 2.
로봇 - Python, 구현 출처 : https://www.acmicpc.net/problem/13901  코드 import sys# 입력 처리data = sys.stdin.read().splitlines()R, C = map(int, data.pop(0).split(" "))room = [[False] * C for _ in range(R)]# 장애물 설치k = int(data.pop(0))for _ in range(k): br, bc = map(int, data.pop(0).split(" ")) room[br][bc] = Truer, c = map(int, data.pop(0).split(" "))commands = list(map(int, data.pop(0).split()))# 1 : up, 2 : down, 3 .. 2025. 3. 26.
파이썬 자주 사용하는 라이브러리 모음 - 코테 꿀팁 1. mathimport mathprint(math.factorial(5)) # 5! = 120print(math.gcd(36, 60)) # 최대공약수(GCD) = 12print(math.sqrt(25)) # 제곱근 = 5.0print(math.ceil(3.1)) # 올림 = 4print(math.floor(3.9)) # 내림 = 32. itertoolsimport itertoolsarr = [1, 2, 3]# 순열 (3개 중 2개를 선택하는 모든 경우) -> 순서 의미 있음print(list(itertools.permutations(arr, 2)))#[(1, 2), (1, 3), (2, 1), (2, 3), (3, 1), (3, 2)]# 조합 (3개 중 2개를 뽑는 경우) -> 순서 .. 2025. 3. 22.