728x90

==> [202302051834908]==============================================
→ TITLE  : ErrorException Occurred
→ DATE   : 2023-02-05 18:34:908
→ URL    : /data/profile/list/user/1948941?pagePerCnt=1&aiVisit=n&pathName=visitor&cnt=NaN
→ METHOD : GET
→ TYPE   : application/json, text/plain, /
→ TOTAL  : 2013822 / KA_0002013822@yeoboya.com
→ MEMBER : 2013822 / KA_0002013822@yeoboya.com
→ AGENT  : InforexAgent(deviceType=IOS, serviceType=b, deviceId=127112AA-5104-419D-AD4E-AD20E19C2C96, appVersion=6.6.136, iAppVersion=60136, phoneVersion=15.2, appProvider=appstore, appChnl=0)
→ ISCOM  : false
→ REF    : https://m.yeoboya.com/profile/list/visitor
→ ERROR  : 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: "NaN"
    at org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver.resolveArgument(AbstractNamedValueMethodArgumentResolver.java:133)

 

이러한 에러가 발생하여 분석한 결과 프로필 열람내역에서 내 프로필 열람 회원이 2회이상 상대 프로필을 방문할때 생기는 상세페이지 버튼이 생기는 데 그부분을 클릭하면 클래스에 'active'가 붙어 열람내역을 확인 할 수 있다. 그런데 실서버에서 쿼리스트링으로 전달하는 부분에서 cnt값이 NaN값이 발생했다. 생기는 환경을 찾아보려고 했으나 쉽지 않았고 생기는 java쪽과 js쪽, html쪽을 찾아보니 버튼 뱃지쪽에 방문횟수 텍스트(숫자)가 없을때 전달하는 인자 cnt값(int)이 들어가지 않아 NaN값으로 들어가서 에러가 났기 때문에 환경적인 부분을 고치는 것 보다 NaN값 처리를  하기로 하여 JS파일에서 처리하였다.

 

 

NaN값일 때 처리

오류화면

html화면

<div class="pf_visit__btn_wrap mt4">
	{{ if (gccv.SEX != user.ptrMemSex && user.totVisitCnt >= 2) || (gccv.SEX != user.ptrMemSex && user.totVisitCnt >= 1 && user.totPfVisitCnt >= 1) }}
	<button class="pf_visit__btn pf_visit__btn-view" id="btn_open" data-aivisit="v" data-cnt="{{user.totVisitCnt}}" style="cursor: pointer">
				<span class="pf_visit__btn_txt" data-aivisit="v" data-cnt="{{user.totVisitCnt}}">
					기본열람
					<span class="pf_visit__btn_num ml2" id="btn_open_num" data-aivisit="v" data-cnt="{{ user.totVisitCnt}}">
						{{ user.totVisitCnt > 99 ? 99 : user.totVisitCnt }}
						</span>
						</span>
	</button>
	{{ /if }}
	{{ if gccv.SEX != user.ptrMemSex && user.totPfVisitCnt >= 1 }}
	<button class="pf_visit__btn pf_visit__btn-all_view {{if user.memSex=='m' && user.pfOpenSlct=='i'}}pr28{{/if}}"
			id="btn_all"
				data-aivisit="n"
				data-cnt="{{user.totPfVisitCnt}}"
				style="cursor: pointer">
				<span class="pf_visit__btn_txt fwb" data-aivisit="n" data-cnt="{{(user.totPfVisitCnt) > 15 ? 15 : (user.totPfVisitCnt)}}">전체열람
				<span class="pf_visit__btn_num {{gccv.SEX == 'm' ? 'pf_visit__btn_num-view' : ''}} ml2" id="btn_all_open_num" data-aivisit="n" data-cnt="{{(user.totPfVisitCnt) > 15 ? 15 : (user.totPfVisitCnt)}}">
						{{ user.totPfVisitCnt > 15 ? 15 : user.totPfVisitCnt }}
				</span>
				</span>
			{{ if gccv.SEX == 'm'}}
				{{ if user.pfOpenSlct == 'i' }}
				<span class="pf_visit__btn_txt_sub" data-aivisit="n" data-cnt="{{user.totPfVisitCnt}}">/&nbsp;정보</span>
				{{ /if }}
				{{ /if }}
				</button>
				{{ /if }}
				<!--			AI 방문횟수					-->
				{{ if gccv.SEX != user.ptrMemSex && user.totVisitCnt >= 1 && user.pfViewYn == 'y' && user.totAiViewCnt >= 1 }}
				{{ /if }}
		</div>

 

오류 해결 JS파일

/**
 * 대상의 방문상세정보를 조회해 옴
 * 성공시 리스트를 프라미스로 넘기고,
 * 실패시 에러를 넘김
 */
fetchVisitDetail (target,aiVisit,cnt) {
   //cnt에 NaN값이 들어올때 상세정보 리스트 처리
   if(isNaN(cnt)){ //cnt가 NaN일때
      if(aiVisit == 'n'){ // aivist(전체열람(n),기본열람(v),AI열람(y)
         cnt = $('#btn_all_open_num').attr('data-cnt');
         $('#btn_all_open_num').text(cnt);
      }else if(aiVisit == 'v'){
         cnt = $('#btn_open_num').attr('data-cnt');
         $('#btn_open_num').text(cnt);
      }else if(aiVisit == 'y'){
         cnt = $('#btn_ai_open_num').attr('data-cnt');
         $('#btn_ai_open_num').text(cnt)
      }
   }
   let pathName = location.pathname.split('/');
   return new Promise((resolve, reject) => {
      axios.get(`/data/profile/list/user/${target.ptrMemNo}?pagePerCnt=${target.totVisitCnt}&aiVisit=${aiVisit}&pathName=${pathName[3]}&cnt=${cnt}`)
         .then(({data}) => {
            if (data.success) {
               resolve(data.list)
            } else {
               reject(new Error(data.msg))
            }
         }).catch(e => {
            reject(e)
         })
   })
}

 

정상적인 화면

클릭시 정상화면

으로 혹시 NaN값이 있을경우에도 태그의 data-cnt값을 받아와서 클릭했을시에 오류도 해결하고 숫자도 나오게되었다.

 

 

728x90
복사했습니다!