포스트맨 에러(쿠키)

류한선·2024년 5월 7일

4차 프로젝트

목록 보기
23/53

"status": 500,
"error": "Internal Server Error",
"trace": "java.lang.NullPointerException: Cannot read the array length because \"array\" is null\r\n\tat java.base/java.util.Arrays.stream(Arrays.java:5428)\r\n\tat
"message": "Cannot read the array length because \"array\" is null",
"path": "/api/v1/articles"

public String getCookie(String name) {
 Cookie[] cookies = req.getCookies();

 if (cookies != null) {
     return Arrays.stream(cookies)
             .filter(cookie -> cookie.getName().equals(name))
             .findFirst()
             .map(Cookie::getValue)
             .orElse("");
 } else {
     return "";
 }
}

이걸 입력해주기

0개의 댓글