본문 바로가기
Issues

Optional int parameter ' ' is present but cannot be translated into a null value due to being declared as a primitive type.

by v-ni 2022. 3. 17.

초보 개발자의 오류일지 01

 

상황

게시글 상세보기로 들어가면 500에러 발생 

 

Error 500 Optional int parameter 'n_no' is present but cannot be translated into a null value due to being declared as a primitive type. 

Consider declaring it as object wrapper for the corresponding primitive type.

 

 

번역기를 돌려본 결과

선택적 int 매개 변수 'n_no'이(가) 있지만 선언되었으므로 null 값으로 변환할 수 없습니다.
해당 기본 유형에 대한 객체 래퍼로 선언하십시오.

 

@GetMapping(value = " ")
public String noticeUpdateForm( int n_no , Model model

 

n_no라는 이름의 파라미터의 값을 받으려고 하는데 해당 값은 정수형 기본 타입인 int형 변수이고 null 값을 받을 수 없으니 객체 래퍼 - Integer로 선언해라 라는 말 같아서 바꿔서 실행했더니....

 

 

 

응??? 

Integer로 바꾸니 에러화면도 안 나오고 내용이 아무것도 안 나온다. 전부 null

Error setting null for parameter #1 with JdbcType OTHER . Try setting a different JdbcType for this parameter or a different jdbcTypeForNull configuration property. Cause: java.sql.SQLException: 부적합한 열 유형: 1111

 

JdbcType OTHER를 사용하여 #1 매개 변수에 대해 null을 설정하는 동안 오류가 발생했습니다. 이 매개 변수에 대해 다른 JdbcTypeForNull 구성 속성을 설정하십시오. 원인: java.sql.SQLException: 부적합한 열  유형: 1111

 

초보에게는 너무나도 어려운 오류해결..

 

이번에는 Integer로 바꾼 게 원인. 

 

처음으로 돌아가서 쭉~~~~~~~~~~~~~~~~~~~ 살펴보니 원인은 너무나도 간단했다!!!

controller문제도 아니었고, mapper 문제도 아니었다.

 

원인은 오.타

망할 오.타

list 뷰단에서 게시글을 클릭 시 상세보기로 넘어가는 onclick 안에 n_no가...

 

<td onclick="location.href='/Notice/noticeDetail?m_no=${notice.n_no}'">${notice.n_no }</td>

m_no로 적혀있었음!!!!

이것때문에 1시간이나 보다니

전혀 예상하지 못한 오류였습니다.